1var element = document.getElementById("#id");
2element.addEventListener('click', function(){
3 console.log("click");
4});
1document.getElementById("example").addEventListener('click', function() {
2 alert('Click');
3});
1const element = document.querySelector(".class__name");
2
3element.addEventListener("click", () => {
4 console.log("clicked element");
5});
1// The anwer of Innocent Ibis is wrong!!
2// It should not have a # for the ID seens we are using getElementById
3var element = document.getElementById("id");
4element.addEventListener('click', function(){
5 console.log("click");
6});
1var element=document.getElementById("some_id");
2var listener=element.addEventListener('click',function(event){
3
4 });