Answers for "get element by data attribute value javascript"

12

js get data attribute

var element = document.querySelector('.element');
var dataAttribute = element.getAttribute('data-name');
// replace "data-name" with your data attribute name

console.log(dataAttribute);
Posted by: Guest on February-03-2020
0

get element by data attribute javascript

document.querySelectorAll('[data-foo]');
Posted by: Guest on April-19-2021

Code answers related to "get element by data attribute value javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language