In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the core functions of jquery". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what core functions jquery has.
The core function of jquery: 1, jQuery (), which is mainly used to obtain the HTML DOM element and encapsulate it as a jQuery object; 2, "jQuery.noConflict ()", which is used to transfer jQuery control of the variable "$".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
JQuery kernel function
The function description jQuery () accepts a string containing a CSS selector for matching a collection of elements. JQuery.noConflict () runs this function to transfer control of the variable $to the library that first implements it. Function description jQuery ():
The jQuery () function is the core function of the jQuery library, and everything in jQuery is based on this function. This function is mainly used to get the HTML DOM element and wrap it as a jQuery object so that you can manipulate the DOM element using other properties and methods provided by the jQuery object.
The jQuery () function is so powerful that it can intelligently encapsulate various types of parameters into jQuery objects.
Grammar
JQuery (selector, [context])
Encapsulates the HTML DOM element corresponding to the selector string selector as a jQuery object. The optional parameter context is used to specify the scope of the lookup DOM element.
JQuery ([obj])
Encapsulates the specified object obj as a jQuery object. This object can be a DOM element (Element), an array of DOM elements, a jQuery object (cloned), or other objects. You can also omit this parameter and return an empty jQuery object.
JQuery 1.4.Use of the new omitted parameter obj: if no parameter is passed in, an empty jQuery object will be returned
JQuery (html, [ownerDocument])
Create a temporary DOM element dynamically based on the HTML tag string html and encapsulate it as a jQuery object. The optional parameter ownerDocument is used to specify in which document the temporary DOM element is created (if there are multiple documents, such as a frame page).
JQuery 1. 0 adds this usage.
JQuery (html, properties)
Based on the HTML tag string html and the properties object containing its additional properties, events, and methods, a temporary DOM element is created dynamically and encapsulated as a jQuery object.
This usage is added to jQuery 1.4.
JQuery (callback)
Executes the specified function callback after the current document has been loaded. This usage is an abbreviation for the ready () function: jQuery (document). Ready (callback).
JQuery 1. 0 adds this usage.
The parameter attribute describes the selector string specified by the selectorString type, which is used to find the corresponding DOM element. The context optional / Object type specifies the scope of the selector string, which can be a DOM element, an array of DOM elements, a document, a jQuery object. If this parameter is omitted, the default is the current document. An object specified by the obj optional / Object type, which is used to encapsulate as a jQuery object. It can be DOM elements, an array of DOM elements, documents, jQuery objects, and so on. The HTML tag string specified by the htmlObject type, such as ","
",
"(tags can also be nested within tags, as long as they conform to html syntax). The ownerDocumentDocument type specifies the document on which the DOM element is temporarily created, and defaults to the current document. An object specified by the propertiesObject type that specifies the properties, events, and methods of the DOM element. For example: {name: "username", "click": the function specified by the function () {}} callbackFunction type, which is used to execute immediately after the DOM document is loaded. Return value
The return value of the jQuery () function is of type jQuery and returns a jQuery object.
Example & description:
JQuery (selector, [context]) sample code:
/ Select all p-tag DOM elements $("p") in the current document; / / Select DOM elements whose id attribute is username ("# username"); / / Select all DOM elements that contain test style (for example: class= "test") $(".test"); / / Select all DOM elements with test style in p tags $("p. Test")
JQuery ([obj] sample code:
Var dom = document.getElementById ("username"); / / encapsulate DOM elements as jQuery objects $(dom); var doms = document.getElementsByName ("book_id"); / / encapsulate an array of DOM elements as jQuery objects $(doms); / / encapsulate body elements as jQuery objects $(document.body)
JQuery (html, [ownerDocument]) sample code:
/ / create a temporary DOM element of an empty span tag and encapsulate it as a jQuery object / / the effect of the following three ways is the same as $(''); / / but this method is not recommended / / to create a p tag containing the test-style span tag $('
'); / / create a table var html =''; html + =''; html + = 'cell 1' positioning html + =''; html + =''; html + = 'cell 3'; html + =''; html + ='; $(cell)
JQuery (html, properties) sample code:
/ / create a temporary link jQuery object var tempLink = $('', {id: 'goback', title:' CodePlayer', html: 'CodePlayer', / / represents the anchor text of the link, that is, the value of innerHTML:' http://www.365mini.com/', click: function () {/ / count the number of clicks}})) / / append to the end of the body tag content tempLink.appendTo ("body"); $(', {type: 'checkbox', val:' def', / / indicates the value attribute value of the form element or the input of textarea click: function () {alert ("clicked the check box");}}) .appendTo ("body")
JQuery (callback) sample code:
(function () {/ / automatically execute alert ("document loaded!");}); / / this is equivalent to the abbreviation of the ready () function $(document) .ready (function () {/ / automatic alert ("document loaded!"); jQuery.noConflict ()
The noConflict () method transfers jQuery control of the variable $.
This method releases jQuery's control over the $variable.
This method can also be used to specify a new custom name for the jQuery variable.
Tip: this method is useful when other JavaScript libraries use $for their functions.
Syntax: jQuery.noConflict (removeAll)
RemoveAll Boolean value. Indicates whether a complete restore of the jQuery variable is allowed.
Thank you for your reading, these are the contents of "what core functions does jquery have". After the study of this article, I believe you have a deeper understanding of what core functions jquery has, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.