What this article brings to you is about the difference between bound events and ordinary events in jquery? The comparison of the differences between bound events and ordinary events in jquery has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. What is the difference between
(“#panel”).bind(“click”,function(){
and
$(“#panel”).click(function(){
?
Binding can add multiple events at the same time
如:$(“#panel”).bind({“click”, “mousemove”, …}) 一次注册多个事件 $(“#panel”).click(function(){}这样是一次注册一个事件 bind(type,[data],fn)
Bind event handler functions to one or more events for each matching element.
$(‘#foo’).bind({ click: function() { // do something on click }, mouseenter: function() { // do something on mouseenter } });
You can pass some additional data before event handling.
<span style="color: #0000ff">function</span><span style="color: #000000"> handler(event) { alert(event.data.foo); } $(“p”).bind(“click”, {foo: “bar”}, handler)<br/>点击p标签后bar传给alert弹出提示</span>
The above is the detailed content of What is the difference between bound events and ordinary events in jquery? Comparison of the differences between bound events and ordinary events in jquery. For more information, please follow other related articles on the PHP Chinese website!