Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

stopImmediatePropagation

<!-- index.html -->

<div id="credit">Procrastination for Dummies</div> 
Copy code
JAVASCRIPT
/* script.js */

const credit = document.querySelector("#credit");

credit.addEventListener("click", function(event) {
  console.log("Nah, I'll do it later");
});

credit.addEventListener("click", function(event) {
  console.log("I WILL do it tomorrow");
  event.stopImmediatePropagation();
});

credit.addEventListener("click", function(event) {
  console.log("Why do I have so much work piled up?!");
});

/* Clicking on the div block will print to the console:

  Nah, I'll do it later
  I WILL do it tomorrow

*/ 
Source by practicum.yandex.com #
 
PREVIOUS NEXT
Tagged: #stopImmediatePropagation
ADD COMMENT
Topic
Name
2+9 =