I want to change the effect (class) of my scroller to the effect on the button a user clicks. Here's my code:
var scroller=$('#main ul.stroll'); --> I know this is right.. just a var reference
function effectSelect(e){
var target = $(e.currentTarget);
$(target).click(function(){
var effectName=target.nodeValue;
var effect='stroll ' + effectName;
scroller.removeClass();
scroller.addClass(effect);
})
}
It worked at a certain point then suddenly stopped working. There are no errors in the console when I run it. What am I doing wrong? Let me know if you need more info
Figured it out finally. Hope this helps anyone in a similar situation!
function init(event) {
stroll.bind($scroller);
$('.nav li').on('click', function(event){
var target = $(event.target);
var effectName = target.text();
var effect = 'stroll ' + effectName;
$scroller.removeClass();
$scroller.addClass(effect);
console.log($scroller.attr('class'))
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.