javascript - how to bind again the click event for the button -
i have button on attaching click event. have unbind after click on it, , later on in code need bind click event on again. tried binding again not works. can't use jquery 'live'. there way create custom bind function on click event , again call ?
$(".submitbutton").click(function(e){ //some functionality on click $(".submitbutton").unbind('click'); }); //somewhere ahead in code $(".submitbutton").bind('click'); apparently isn't working. there way tackle ?
your .bind call doesn't seem correct. haven't specified callback.
so start writing function:
function handlebuttonclick() { //some functionality on click $(this).unbind('click'); } notice inside handler unbinding $(this) element being clicked , not elements class="submitbutton". , then:
$('.submitbutton').bind('click', handlebuttonclick); and later when want rebind:
$('.submitbutton').bind('click', handlebuttonclick); and on.
Comments
Post a Comment