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