setAttribute data set jasvcirpt 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!');