jquery - changing classes and adding click event -


i changing current class on first click event , class replaced have own click event. here current attempt:

$(".originalbutton").on("click", function(){   // works, changes class.   $(this).closest(".questions").find(".originalbutton").removeclass("originalbutton").addclass("correctbutton").off("click"); }); 

now right under event handler added this:

$(".correctbutton").on("click", function(){   debugger;  }); 

ideally have else instead of debugger, @ point event isn't firing when correctbutton class button clicked, though when inspect element class updated (from first click event).

you need use event delegation adding/removing classes dynamically . use:

$(".questions").on("click",'.correctbutton', function(){    debugger; }); 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -