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});
1const element = document.querySelector(".class__name");
2
3element.addEventListener("click", () => {
4 console.log("clicked element");
5});
1document.querySelector("button").addEventListener("click", handle);
2
3function handle() {
4 alert("I got clicked")
5}
1element.addEventListener("click", function(){
2 element.innerText = "something";
3});