Pengaturan, mendapatkan, dan menghapus atribut data vanilla javascript
// setting data-foo
var el = document.querySelector('div');
el.setAttribute('data-foo', 'Hello World!');
// getting data-foo
var el = document.querySelector('img');
console.log(el.getAttribute('data-foo'))
// removing data-foo
el.removeAttribute('data-foo');
Uninterested Unicorn