Answers for "data- js"

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
5

javascript get data attribute value

const article = document.querySelector('#electric-cars');
 
article.dataset.columns // "3"
article.dataset.indexNumber // "12314"
article.dataset.parent // "cars"
Posted by: Guest on April-15-2020
0

javascript data

document.getElementById("year").innerHTML = new Date().getFullYear();
Posted by: Guest on October-27-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language