Jquery bind() method


The bind() method was deprecated in version 3.0. Use the on() method instead. The jQuery bind() event is used to attach one or more event handlers for selected elements from a set of elements. It specifies a function to run when the event occurs. So we can say that The bind() method attaches one or more event handlers for selected elements, and specifies a function to run when the event occurs.

Syntax:


$(selector).bind(event,data,function,map)



Example :-

<!DOCTYPE html>
<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script>
$(document).ready(function(){
    $("p").bind("click", function(){
        alert("The paragraph was clicked.");
    });
});
  </script>
</head>
<body>

  <p>Click here to see the magic of bind() method!</p>

</body>
</html>