Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the concept of bind in jquery

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Today, I would like to share with you the relevant knowledge about the concept of bind in jquery. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

In jquery, bind means "binding" and is used to bind an event to a specified element and set the handler function that runs when the event occurs; the syntax "element object .bind (event,data,function)", the parameter event specifies that events that need to be bound to the element can have multiple values, but they need to be separated by spaces.

The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.

In jquery, bind means "bind" and is used to bind events to specified elements and to set one or more event handlers.

The bind () method adds one or more event handlers to the selected element, as well as functions that run when the event occurs.

The syntax for binding events and functions to elements:

The $(selector) .bind (event,data,function) parameter describes event

Necessary. Specifies one or more events to be added to the element.

Multiple events are separated by spaces. Must be a valid event.

Data is optional. Specifies the additional data passed to the function. Function is required. Specifies the function to run when an event occurs.

Example 1: bind the click event and set the handler

Effect achieved: hide or show the p element when the mouse is clicked

$(document) .ready (function () {$("button") .bind ("click", function () {$("p") .slideToggle ();}) Hide or show the p element.

This is a p paragraph.

This is a p paragraph.

Example 2: bind multiple events

$(document) .ready (function () {$("p") .bind ("mouseover mouseout", function () {$("p") .toggleClass ("intro");}) .intro {font-size: 150%; color: red;}

Move the mouse over the paragraph.

These are all the contents of the article "what is the concept of bind in jquery?" Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report