Answers for "javascript get event on click"

47

javascript onclick event listener

document.getElementById("myBtn").addEventListener("click", function() {
  alert("Hello World!");
});
Posted by: Guest on July-10-2020
2

javascript onclick get event

<div onclick="doSomething(event,this)"></div>
<script>
     function doSomething(e,el){
         e = e || window.event;
         console.log(e); //will be the event
         console.log(el); //we be the dom element 
     }
</script>
Posted by: Guest on November-30-2020

Code answers related to "javascript get event on click"

Browse Popular Code Answers by Language