⊗jsPmAtDM 373 of 504 menu

Accessing to attributes via methods in JavaScript

Custom attributes can also be accessed using methods like getAttribute, in which case the full name of the attribute should be written:

<div id="elem" data-num="1000" data-my-num="2000"></div> let elem = document.querySelector('#elem'); console.log(elem.getAttribute('data-num')); // shows 1000 console.log(elem.getAttribute('data-my-num')); // shows 2000

Given paragraphs. Go through them in a loop and for each paragraph write down the ordinal number of this paragraph into the data-num attribute. Use the setAttribute 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