Home >Web Front-end >JS Tutorial >What is the difference between bound events and ordinary events in jquery? Comparison of the differences between bound events and ordinary events in jquery

What is the difference between bound events and ordinary events in jquery? Comparison of the differences between bound events and ordinary events in jquery

不言
不言Original
2018-09-17 17:40:521738browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn