html - stopPropagation in Javascript -
i want overlay fire click
event. click
goes of on every childnode.
class="snippet-code-js lang-js prettyprint-override">function something(e) { e.stoppropagation(); console.log('its fired'); }
class="snippet-code-css lang-css prettyprint-override">#overlay { width: 100%; } #image-wrapper { width: 50%; }
class="snippet-code-html lang-html prettyprint-override"><div id="overlay" onclick="something"> <div id="image-wrapper"> <img src="image.jpg" id="popupimage" alt="[image]"> </div> </div>
i don't want fire click
on image. in overlay.
you can preventdefault()
on img
$("img").click(function(e){ e.preventdefault(); e.stoppropagation(); console.log("stop click"); });
fiddle
javascript html
No comments:
Post a Comment