Search
 
SCRIPT & CODE EXAMPLE
 

HTML

stopimmediatepropagation vs stoppropagation

<!---- stopImmediatePropagation() vs stopPropagation() ----------------->

`stopPropagation` allows other event handlers on the SAME ELEMENT 
on the SAME EVENT to be executed, while `stopImmediatePropagation`
prevents this.

<script>
el.addEventListener( "click", e => e.stopImmediatePropagation() )
el.addEventListener( "click", e => console.log("This will not run.") )
</script>

<!----------------- stopImmediatePropagation() vs stopPropagation() ---->
Comment

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

*/ 
Comment

PREVIOUS NEXT
Code Example
Html :: how to download a file from html button 
Html :: disable overscrolling 
Html :: input number limit digits 
Html :: change date format in html 
Html :: reload tab using meta 
Html :: navigation bar on more than one page 
Html :: how to embed a website in another website 
Html :: arnav.tcode.in 
Html :: html tel link 
Html :: how to use figure and caption in html 
Html :: how add float input type in html 
Html :: html date min max 
Html :: navba using bootstrap 
Html :: how to align 2 buttons in a div 
Html :: form action without redirect 
Html :: access particular array index in html template django 
Html :: sudo: /opt/lampp/lampp: command not found 
Html :: what is the html code of changing color 
Html :: svg icon not showing html 
Html :: html image in table 
Html :: path width svg change 
Html :: HTML <i and <em Elements 
Html :: index html example 
Html :: bootstrap vertical hr 
Html :: refresh icon font awesome 
Html :: og tags 
Html :: tailwind border width 
Html :: form tag radio 
Html :: html shortcuts 
Html :: responsive flexbox navbar 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =