Unbind button click event

Description

The following code shows how to unbind button click event.

Example


<html>
<head>
<script type="text/javascript"
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--from  w ww  .ja  v  a 2  s  . c  o  m-->
    function aClick() {
      alert("action");
    }
    $("#bind").click(function() {
      $("#myButton").click(aClick).text("Binded");
    });
    $("#unbind").click(function() {
      $("#myButton").unbind('click', aClick).text("Not Binded");
    });

  });
</script>
</head>
<body>
  <button id="myButton">Not Binded</button>
  <button id="bind">Bind Click</button>
  <button id="unbind">Unbind Click</button>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities