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

How to implement bind function to bind multiple events

小云云
Release: 2018-01-30 09:41:13
Original
2317 people have browsed it

This article mainly introduces how jQuery uses the bind function to bind multiple events. It analyzes the operation skills and precautions of jQuery using the bind function to bind multiple events in the form of a simple example. Friends in need can refer to the following , hope it can help everyone.

When binding multiple event names in jQuery, use spaces to separate them. For example:

$("#foo").bind("mouseenter mouseleave", function() {
 $(this).toggleClass("entered");
});
Copy after login

After version 1.4, you can also bind as follows

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

Related Recommended:

Detailed description of jquery events and binding events

Javascript uses event attributes to bind event functions. Detailed explanation of usage

Introduction to the difference between binding events bind and live in Jquery

The above is the detailed content of How to implement bind function to bind multiple events. 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