set data value javascript code example
Example: how to set data attribute in js using setattribute
// setting data-foovar el = document.querySelector('div');el.setAttribute('data-foo', 'Hello World!');
// setting data-foovar el = document.querySelector('div');el.setAttribute('data-foo', 'Hello World!');