Home  >  Article  >  Web Front-end  >  How to implement bind function to bind multiple events

How to implement bind function to bind multiple events

小云云
小云云Original
2018-01-30 09:41:132315browse

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");
});

After version 1.4, you can also bind as follows

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

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!

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