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

不言
Release: 2018-09-17 17:40:52
Original
1707 people have browsed it

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(){
Copy after login

and

$(“#panel”).click(function(){
Copy after login

?

Binding can add multiple events at the same time

如:$(“#panel”).bind({“click”, “mousemove”, …}) 一次注册多个事件

$(“#panel”).click(function(){}这样是一次注册一个事件

bind(type,[data],fn)
Copy after login

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
}
});
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template