javascript - jQuery .off() not removing handlers -
i have dynamically loaded button created when document loads. after this, attach click handler button. when try remove handler .off(), not work.
this snippet creates click handler , removes it. however, when click button, function startmash still executes.
$(document).on("click", "#mash-idle-start", startmash); $("#mash-idle-start").off(); obviously not functionality trying achieve, problem persists through simple example
because event handler not attached #mash-idle-start, attached document so
$(document).off("click", "#mash-idle-start", startmash); or
$(document).off("click", "#mash-idle-start"); note: when working event unbinding, try use event namespaces have more control on handlers removed.
Comments
Post a Comment