Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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');
Source by www.sitepoint.com #
 
PREVIOUS NEXT
Tagged: #custom #data #attribute #javascript
ADD COMMENT
Topic
Name
4+4 =