⊗jqSeCMU 86 of 113 menu

Using the contents method in jQuery

To return all descendants, including text, use the contents method.

Below is the HTML code:

<p id="test">text1 <b>bold</b> text2</p>

Now let's use the method contents:

$('#test').contents().each( function() { console.log($(this).text()); // will bring out 'text1', 'bold', 'text2' } );

Correct the code for solving the previous problem, output all the children of the div, including the text, using the contents method.

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