Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2005
    Posts
    153
    Thanks
    26
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder Amphiluke's Avatar
    Join Date
    Jul 2009
    Posts
    312
    Thanks
    3
    Thanked 89 Times in 89 Posts
    Try this:
    Code:
    $(document).ready(function(){
        $("#mainwindow").live("mouseup",function(e){
            if ($(e.target).is("#mainwindow")) alert("testing");
        });
    });
    I am still learning English

  • Users who have thanked Amphiluke for this post:

    questionable (11-20-2011)

  • #3
    Regular Coder
    Join Date
    Jun 2005
    Posts
    153
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Awesome Thanks


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •