In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "jQuery how to deal with HTML events", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "jQuery how to deal with HTML events" this article.
JQuery event function
JQuery is specially designed for event handling.
The jQuery event handling method is the core function in jQuery.
Event handlers refer to methods that are called when certain events occur in the HTML.
You usually put jQuery code in a partial event handling method:
$(document) .ready (function () {$("button") .click (function () {$("p"). Hide ();}); This is a heading
This is a paragraph.
This is another paragraph.
Click me
Note: when the click event of a button is triggered, a function is called, which hides all
element.
Functions in separate files
If your site contains many pages and you want your jQuery function to be easy to maintain
Then put your jQuery function in a separate .js file, and then reference the file through the src property:
JQuery name conflict
JQuery uses the $symbol as an introduction to jQuery.
Functions in some other JavaScript libraries, such as Prototype, also use the $symbol.
JQuery uses a method called noConflict () to solve this problem.
Var jq=jQuery.noConflict (), which helps you use your own name (such as jq) instead of the $symbol.
$.noConflict (); jQuery (document) .ready (function () {jQuery ("button") .click (function () {jQuery ("p") .text ("jQuery is still running!") ;})
This is a paragraph.
Test jQuery
JQuery maintenance
JQuery is specially designed to handle HTML events, following the following principles to make the code more appropriate and easier to maintain:
Put all the jQuery code in the event handler
Place all event handlers in the document ready event handler
Put the jQuery code in a separate .js file
If there is a name conflict, rename the jQuery library
JQuery event method
$(document) .ready (function): binds a function to a document's ready event (when the document finishes loading)
$(selector) .click (function): a click event that triggers or binds a function to the selected element
$(selector) .dblclick (function): a double-click event that triggers or binds a function to the selected element
$(selector) .focus (function): the focus event that triggers or binds the function to the selected element
$(selector) .Mouseover (function): a mouse over event that triggers or binds a function to the selected element
The above is all the content of the article "how jQuery handles HTML events". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to 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.