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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -