Answers for "data-item html"

0

how to can i get custom data attribute value in javascript

example <button data-keyname = "a'></button>

let variable = element.dataset.keyname;
or
let varibale = element.['keyname'];
or
let variable = element.getAttribute('data-keyname');
Posted by: Guest on December-31-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language