Saturday 9 June 2018

How to temporarily disable a button click in jQuery?

<script>
$("#button_id").click(function() {
  if($(this).data('dont')==1) return;
  $(this).data('dont',1);

  // Do Process .....

  $(this).data('dont',0);
}

///////// OR /////////

$("#button_id").click(function() {
  if($("#button_id").data('dont')==1) return;
  $("#button_id").data('dont',1);

  // Do Process .....

  $("#button_id").data('dont',0);
}
// Note: Remeber that $.data() would work only for items with ID.
</script>

No comments:

Post a Comment