JS equivalent for jQuery one()

后端 未结 5 1006
执念已碎
执念已碎 2020-12-14 22:34

Can someone point me towards a solution for the following? I\'m trying to find a JS equivalent for this jQuery code:

var formSelector = \'my selector here\';         


        
5条回答
  •  轮回少年
    2020-12-14 23:41

    Here's a really simple solution using data attributes.

    document.querySelector('#click').addEventListener('click', function(e){
        if(e.currentTarget.dataset.triggered) return;
        e.currentTarget.dataset.triggered = true;
        alert('clicked');
    })

提交回复
热议问题