Answers for "allow attaching a handler for an event that is defined in an element other than the one adding the handler."

9

javascript click event

<button onclick="myFunction()">Click me</button>

<p id="demo"></p>

<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Hello World";
}
</script>
Posted by: Guest on April-10-2020
3

javascript event listener

element.addEventListener("click", function(){ 
   element.innerText = "something"; 
});
Posted by: Guest on February-19-2020

Code answers related to "allow attaching a handler for an event that is defined in an element other than the one adding the handler."

Browse Popular Code Answers by Language