I use native js and I need get value from data-atribute all elements which I click on.
window.onload = function() {
let btn = document.getElementsByClassName('btn');
for( let i = 0; i < btn.length; i++ ) {
btn[i].addEventListener( "click" , function(e) {
let dataBtn = e.getAttribute('data-btn');
console.log(dataBtn);
});
}
};
But I get error (e.getAttribute is not a function)
Have I can get and use this in native js?