Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

get data attribute javascript

// <div id="element" data-name="john"></div>

const el = document.querySelector('#element')
el.dataset.name // 'john'
 
PREVIOUS NEXT
Tagged: #data #attribute #javascript
ADD COMMENT
Topic
Name
8+9 =