The examples in this article describe the usage of the jQuery() method in jQuery. Share it with everyone for your reference. The details are as follows:
Definition and usage of jQuery() method:
This method can accept a set of selectors to match the corresponding elements. For example:
In practical applications, $ is generally used to define jQuery. In fact, $ is the abbreviation of jQuery. For example, $("li") can be written as jQuery("li").
The core functions of jQuery are all implemented through this method, or are implemented using this method in some way. The following is a detailed introduction to the usage of this method.
Grammar structure 1:
When the jQuery() method does not have any parameters, it will return an empty jQuery object.
Grammar structure 2:
If not specified, it is the entire current document.
Example code:
Example 1:
The sun is out
The above code can set the font color in the li element to red.
Example 2:
The sun is out
The above code sets the font color in the li element in the div to red.
Grammar structure three:
Convert DOM elements and DOM element arrays into jQuery objects.
Parameter list:
Example code:
Example 1:
The sun is out
The above code can set the font color in the li element with id first to red.
Example 2:
The sun is out
Grammar structure four:
Example code:
The function is the same as the following code:
I hope this article will be helpful to everyone’s jQuery programming.