Vanilla JavaScript version of jQuery .click

后端 未结 7 665
孤城傲影
孤城傲影 2020-12-07 22:24

So maybe I\'m just not looking in the right places but I can\'t find a good explanation of how to do the equivalent of jQuery\'s

$(\'a\').click(function(){
          


        
7条回答
  •  孤城傲影
    2020-12-07 22:56

    element.addEventListener('click', function() { ... }, false);
    

    You have to locate the elements and make a loop to hook up each one.

提交回复
热议问题