In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article, "what are the on () parameters of jquery?", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "what are the on () parameters of jquery?"
The on () method has four parameters: 1, the first parameter can not be omitted, which specifies one or more events or namespaces to be added from the selected element; 2, the second parameter can be omitted to specify the event handler of the element; 3, the third parameter can be omitted to specify the additional data passed to the function; 4, the fourth parameter can be omitted to specify the function to run when the event occurs.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
The jquery on () method adds one or more event handlers to the selected element and its children.
Since jQuery version 1.7, the on () method is a new alternative to the bind (), live (), and delegate () methods. This method brings a lot of convenience to API, and we recommend it, which simplifies the jQuery code base.
Note: event handlers added using the on () method apply to current and future elements (such as new elements created by scripts).
The jquery on () method can accept 4 parameters
The $(selector) .on (event,childSelector,data,function) parameter is required to describe event. Specifies one or more events or namespaces to add from the selected element.
Multiple event values are separated by spaces, which can also be arrays. Must be a valid event. ChildSelector is optional. Specifies that event handlers can only be added to specified child elements (and not the selector itself, such as the obsolete delegate () method). Data is optional. Specifies the additional data passed to the function. Function is optional. Specifies the function to run when an event occurs.
Example 1: to
Element to add a click event handler
$(document) .ready (function () {$("p") .on ("click", function () {alert ("paragraph has been clicked.") ;})
Click on this paragraph.
Example 2: add multiple event handlers
$(document) .ready (function () {$("p") .on ("mouseover mouseout", function () {$("p") .toggleClass ("intro");}) .intro {font-size: 150%; color: red;}
Move the mouse pointer over the text.
Example 3: add event handlers to future elements
$(document) .ready (function () {$("div") .on ("click", "p", function () {$(this) .ready ();}) $("button") .click (function () {$("
This is a new paragraph.
). InsertAfter ("button");});})
This is a paragraph.
Click any p element to make it disappear. Including this paragraph.
Insert a new p element after this button
The above is about the content of this article on "what are the on () parameters of jquery?" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.