mardi 4 août 2020

How to a data from the element that i clicked using "This" in JS?

I want to get a data from the element that i clicked using this in JavaScript?

but insisted of the data it's return undefined.

function jj(){
    let yty = this.num;
    console.log(yty);
}
li {
width:200px;
}
<button num="2" onclick="jj()">3</button>



Aucun commentaire:

Enregistrer un commentaire