⊗jqSeIn 70 of 113 menu

Basics of Working with Sets in jQuery

Now we will start learning jQuery methods for working with a set of elements. They are very convenient to use when building method chains.

First, let's get the set of elements corresponding to the jQuery object. This can be done using the get method, so we can get all the paragraphs:

console.log($('p').get());

You can also get a specific paragraph, then you need to specify a specific element number in the set. The number can also have a negative value (then the count is in the opposite direction from the last element). Let's get the second paragraph using the get method, the count is from 0 and output it to the console:

<p>text</p> <p>test</p> <p>text</p> <p>text</p> console.log($('p').get(1));

Get 5-th li and print it to the console.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline