javascript - How to change a class to the nodeValue of the element? What am I doing wrong? -
i want alter effect (class) of scroller effect on button user clicks. here's code:
var scroller=$('#main ul.stroll'); --> know right.. 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 @ point stopped working. there no errors in console when run it. doing wrong? allow me know if need more info
figured out finally. hope helps in 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')) }); }
javascript jquery button onclick scroller
No comments:
Post a Comment