Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-20-2011, 05:16 PM   PM User | #1
questionable
Regular Coder

 
Join Date: Jun 2005
Posts: 153
Thanks: 26
Thanked 0 Times in 0 Posts
questionable is an unknown quantity at this point
Clicking on Child shouldn't trigger parent

Hello All,

Alright this problem has me a little confused. I have the following code and can't seem to get it to work:

Code:
<style>
	#mainwindow
	{
		position: absolute;
		height: 100%;		
		border: thin red solid;
	}
	
	.divs
	{
		border: thin blue solid;
	}
</style>
<script src="jquery.js"></script>
<script>
	$(document).ready(function(){
		$("#mainwindow:not(.divs)").live("mouseup",function(e){
			e.stopPropagation();
			alert("testing");
		});
	});
</script>
<div id="mainwindow">
	<div class="divs">
		This is an area that when the mouse comes back up it should not alert.
	</div>
</div>
Here is a little model of what I'm trying to get the code to do. There are two div. One inside of the other. I would like it when the mouse button is brought back up that it wouldn't alert if it was brought up inside the child div and not the parent div. I know I could use the .live("click" .... but I plan on having it do more so I just left it as mouseup in the mean time.

Any help would be greatly appreciated!

-questionable
questionable is offline   Reply With Quote
Old 11-20-2011, 06:39 PM   PM User | #2
Amphiluke
Regular Coder

 
Amphiluke's Avatar
 
Join Date: Jul 2009
Posts: 312
Thanks: 3
Thanked 89 Times in 89 Posts
Amphiluke is on a distinguished road
Try this:
Code:
$(document).ready(function(){
    $("#mainwindow").live("mouseup",function(e){
        if ($(e.target).is("#mainwindow")) alert("testing");
    });
});
__________________
I am still learning English
Amphiluke is offline   Reply With Quote
Users who have thanked Amphiluke for this post:
questionable (11-20-2011)
Old 11-20-2011, 08:22 PM   PM User | #3
questionable
Regular Coder

 
Join Date: Jun 2005
Posts: 153
Thanks: 26
Thanked 0 Times in 0 Posts
questionable is an unknown quantity at this point
Awesome Thanks
questionable is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:00 AM.


Advertisement
Log in to turn off these ads.