//javascript get html data attribute code example
Example 1: get data attribute javascript
//
const el = document.querySelector('#element')
el.dataset.name // 'john'
Example 2: javascript get data attribute value
const article = document.querySelector('#electric-cars');
article.dataset.columns // "3"
article.dataset.indexNumber // "12314"
article.dataset.parent // "cars"