⊗jsPmNdNm 395 of 504 menu

Node name in JavaScript

All nodes have the property nodeName. For a comment, it contains the value 'comment', for a text node, the value 'text', and for an element node, the tag name in uppercase. It turns out that nodeName for elements is similar to the property tagName, but works for other types of nodes as well.

Given a div:

<div id="elem">txt<b>tag</b><!--com-->txt<b>tag</b><!--com--></div>

Loop through all the nodes of this div and print their names 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