Home >Web Front-end >Front-end Q&A >what is jquery wrapper set
In jquery, the packaging set refers to a set of elements filtered out by the "$()" method; the packaging set can be understood as an object array, and the size() method can be used to view the elements in the packaging set The number, use the "get(index)" method to obtain an element in the packaging set.
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
By using $("exp"), a group of elements in the page will be filtered out. This group of elements is called a packaging set.
The packaging set is actually an array. You can use the size() method to check the number of elements in the packaging set. You can use the get(index) method to get an element in the packaging set and get a js element.
The jQuery wrapper set refers to a set of elements returned through the $() method, which is different from the general JavaScript array. The wrapper set also has some initialization functions and properties based on the latter. We can compare the two:
jsdiv = document.getElementsByTagName("div"); jqdiv = $("div"); // javascript 元素集 console.log(jsdiv); // jquery 包装集 console.log(jqdiv);
Use firebug to debug and check the returned object:
You can see that document.getElementsByTagName(" div") returns an HTMLCollection element set. And $("div") returns an object. This object contains three div elements, which we can access through the jqdiv[n] method. At the same time, this object also contains some attributes (such as the length attribute) and methods ( For example, add(), append() methods), these methods and properties are common to all packaging sets.
Recommended related video tutorials: jQuery video tutorial
The above is the detailed content of what is jquery wrapper set. For more information, please follow other related articles on the PHP Chinese website!