Hi Reader's,
Welcome to FindNerd, today we are going to discuss how to use bind() Method in Jquery.
The bind()methods is one of the most important aspects of dealing with events through jQuery.
Basically,the bind() method affixes one or more event handlers for culled elements, and designates a function to run when the event occurs.
Syntax of bind() Method
$(selector).bind(event,data,function,map)
event and function both are required parameter.
you can see below example:
<!DOCTYPE html>
<html>
<head>
<!-- here add jquery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
//here call bind() method
$("p").bind("click", function(){
//alert success message
alert("success ! clicked.");
});
});
</script>
</head>
<body>
<!-- define here paragraf -->
<p>Click alert !</p>
</body>
</html>
0 Comment(s)