Jquery binding click event method: [$("#text").bind("click",function(){});]. The bind method adds one or more event handlers to the selected element and specifies the function to run when the event occurs.
The operating environment of this tutorial: Windows 10 system, jquery version 2.2.4. This method is suitable for all brands of computers.
(Learning video sharing: jquery video tutorial)
Function introduction:
bind() method adds one or more events to the selected element handler and specifies a function to run when an event occurs.
Syntax:
$(selector).bind(event,data,function)
Parameters:
<script type="text/javascript"> $(document).ready(function(){ $("#text").bind("click",function(){ alert("我的id为text,你点击时触发"); }); $("#text1").on("click",function(){ alert("hellworl"); }); $("#text2").click(function(){ alert($("#text2").val()); }); }); </script> <body> <input id="text" type="button" value="点击"/> <input id="text1" type="button" value="点击"/> <input id="text2" type="text" value="love"/> </body>
The above is the detailed content of How to bind click event in jquery. For more information, please follow other related articles on the PHP Chinese website!