1let test = document.getElementById("test");
2
3test.addEventListener("mouseover", function( event ) {
4 alert("mouse over test!")
5 , false);
1document.getElementById("myBtn").addEventListener("click", function() {
2 alert("Hello World!");
3});
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});