⊗jqBsDBP 28 of 113 menu

Difference between :parent and parent() in jQuery

In addition to the pseudo-class :parent, there is also a method parent, which allows you to select the parent of an element.

Let us have the following paragraphs:

<p>text with <b>b</b> tag</p> <p>text</p>

Let's, for example, find the parent of the tag b and set it to red:

$('b').parent().css('color', 'red');

Get and color red the parent of the li tag with class www (li with class www, not the parent).

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