Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

jQuery Selector & Exclusion

Posted on 2009-06-30
3
Medium Priority
?
609 Views
Last Modified: 2012-05-07
I have the following codes, basically the alert should only fire if the user moves the cursor outside of the main box, it should never fire inside even when switching hover between div's inside the main box. That's why I tried :not(#main *), but that doesn't seem to work.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>Test Page</title>
		<style>
			#body-content
			{
				margin:50px 0px; 
				padding: 0px;
				text-align: center;
			}
			
			#main {
				width:800px;
				height: 500px;
				margin:0px auto;
				text-align:left;
				padding:15px;
				border:1px dashed #333;
				background-color:#eee;
			}
			
			#navbar {
				background-color: #cc0000;
				margin-bottom: 250px;
			}
		</style>
		<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
		<script>
			$(document).ready(function(){		
				$("*:not(#main *)").mouseover(function(){
					alert("mouse out");
				}, function() {});
			});
		</script>
	</head>
 
	<body id="body-content">
		<div id="main">	
			<div id="navbar">
				Heres the navigation bar menu....
			</div>
			<div id="box">
				Heres some content in the box....
			</div>
		</div>
	</body>
</html>

Open in new window

0
Comment
Question by:jwzk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
Lakio earned 2000 total points
ID: 24752670

Use mouseleave
http://docs.jquery.com/Events/mouseleave
or hover( I think that also works )
http://docs.jquery.com/Events/hover
0
 

Author Comment

by:jwzk
ID: 24753301
Wow, didn't know that existed. Mouseleave is exactly what I was looking for, thanks!
0
 

Author Closing Comment

by:jwzk
ID: 31598652
Exactly what I was looking to do
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question