Home  >  Article  >  Web Front-end  >  what is jquery wrapper set

what is jquery wrapper set

WBOY
WBOYOriginal
2022-05-18 10:04:591699browse

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.

what is jquery wrapper set

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

What is jquery packaging set

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:

what is jquery wrapper set

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn