javascript - How can I remove an attached jQuery function programatically? -
in $.ready() have declared click function shown below
$(document).ready(function(){ $("#btnclk").click(function(clkevent){ //doing here clkevent.preventdefault(); }); }); i want remove click() $("#btnclk") in javascript function. how can this?
one of problems proposed solutions remove click event handlers registered, may not desired.
a solution separate handler method out common scope shared both participating methods use method reference along .off() resolve this
function btnclickhandler(clkevent){ //doing here clkevent.preventdefault(); } $(document).ready(function(){ $("#btnclk").click(btnclickhandler); }); $("#btnclk").off('click', btnclickhandler);
Comments
Post a Comment