shortysbest Posted June 14, 2011 Share Posted June 14, 2011 I am working on making a photo gallery and I want it to close when you click anything but the photo and other contents of the gallery, I can't figure out how to make this work though. I have a function that should stop propagation for bot IE and everything else: function stopagation(e) { if (!e) e = window.event; if (e.cancelBubble) e.cancelBubble = true; else e.stopPropagation(); } Then my script for closing the gallery would be: $(".photo-gallery-wrapper").click(function(event){ stopagation(event); $(".photo-gallery-wrapper").fadeOut("fast"); }); My gallery setup (just the very basic of it looks like: <div class="photo-gallery-wrapper"> <div class="photo-gallery-container"> <img src="photos/<?php print $photo_id?>_440.jpg" /> </div> </div> Quote Link to comment https://forums.phpfreaks.com/topic/239344-stop-propagation-how-to-use/ Share on other sites More sharing options...
Omirion Posted June 16, 2011 Share Posted June 16, 2011 Why not just use JQ's stop propagation method? Or am i falsely assuming you are using jQuery? In any case. $("p").click(function(event){ event.stopPropagation(); // do something }); Quote Link to comment https://forums.phpfreaks.com/topic/239344-stop-propagation-how-to-use/#findComment-1230392 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.