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
Post a Comment