News from the Field
A channel with tips on modern AI development. Join!
⊗jsPmNdTp 396 of 504 menu
◀ ▶

Node type in JavaScript

All nodes have the property nodeType. Its value is numeric: 1 for elements, 3 for text nodes, 8 for comments. The remaining values are currently either little used or outdated.

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 output only the element nodes and text nodes 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