Home > Web Front-end > JS Tutorial > body text

Detailed explanation of jQuery bind event usage

巴扎黑
Release: 2017-06-25 11:01:55
Original
1459 people have browsed it

I haven’t written anything for a long time. I only discovered it when I encountered a problem at work today. In the future, I will have to force myself to take more time to write my own things, and also share with you the problems I encountered at work.

I have been using jquery for nearly a year. Today I was looking at the code of a foreign expert and suddenly found a place that I didn’t understand. The code is as follows

 $(window).bind('load.jcarousel', function() { windowLoaded = true; });

Maybe I don’t know much about jQuery. I have only read an introductory book on jQuery, and then I always study on the job and encounter problems. Let’s summarize a little and learn a little... Hey, maybe why companies always recruit people with more than 1 year of work experience or something. It is true that actual practice is the fastest way for people to improve.

Find the jQuery API, which is explained as follows:

1. Multiple events can be bound at one time. For example:

The code is as follows:

$('#foo').bind({ 
click: function() { 
// do something on click 
}, 
mouseenter: function() { 
// do something on mouseenter 
} 
}); 
Copy after login


2. Any string used as the type parameter is legal; if a string is not native The JavaScript event name, then this event handling function will be bound to a custom event. These custom events are never triggered by the browser, but can be triggered manually in other code by using .trigger() or .triggerHandler().

3. If the string of the type parameter contains a dot (.) character, then this event is regarded as having a namespace. This dot character is used to separate the event from its namespace. For example:

$obj.bind('click.name', handler) Then the click in the string is the event type, and the string name is the namespace.

Okay, that’s it, I’m going home from get off work. This month, let’s summarize a jQuery development model. Be sure to be prepared. Finally, I hope this article can be helpful to you.

The above is the detailed content of Detailed explanation of jQuery bind event usage. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!