Hi everyone! I'm the author of code.mu :)
I'd love to chat with my non-Russian audience. I'm looking for your feedback on the site and the translation quality. Let's chat:)
⊗jsPmAtDHN 372 of 504 menu
◀ ▶

Hyphenated names of attributes in JavaScript

Custom attributes can contain hyphens in their names, like this:

<div id="elem" data-my-test="1000"></div>

To refer to such attributes, use camelCase:

let elem = document.querySelector('#elem'); console.log(elem.dataset.myTest);

Given the following code:

<div id="elem" data-product-price="1000" data-product-amount="5"> apples </div>

Make it so that when you click on the div, the purchase price is added to the end of its text, equal to the price multiplied by the quantity.

← →
↑
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