我有多个具有相同类名的 html 元素,我想知道在纯 javascript 中单击了哪个元素
<a href="#" data-wow="1" class="wow">link a</a>
<a href="#" data-wow="2" class="wow">link a</a>
<a href="#" data-wow="3" class="wow">link a</a>
Run Code Online (Sandbox Code Playgroud)
在 javascript 中,我尝试了很多解决方案,但我发现所有解决方案都只能使用一个元素
到目前为止我写了什么
var dd = document.getElementsByClassName('messages-email');
dd.onclick() = function(ee){
// if i clicked the first link i want to get data-wow which is 1
// and if i clicked the third one i wanna get data-wow which is 3
console.log('i want the clicked elemet attribute ')
}
Run Code Online (Sandbox Code Playgroud)