addEventListener Executing Before Being Clicked

前端 未结 2 449
被撕碎了的回忆
被撕碎了的回忆 2021-01-28 01:18

I\'m Developing a basic Chrome extension centred around a video game. In order to create the menu I have used HTML and come up with:

    
        <         


        
2条回答
  •  無奈伤痛
    2021-01-28 01:39

    You only need to pass the reference, as second parameter is a callback

    document.querySelector("#startButtonImage").addEventListener('click', startGame);
    document.querySelector("#infoButtonImage").addEventListener('click', openInfo);
    

提交回复
热议问题