I'm trying to build a site with a navigation menu which toggles class upon hovering over the navigation buttons which are not currently "selected" or "active". Here is a simple version of the code:
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<style type="text/css">
ul li a.selected {font-weight:bold;}
ul li a.hover {color:yellow;}
div.page {position:absolute;}
</style>
<script type="text/javascript">
$(function(){
$("div.page:not(:first)").hide(); // hide all pages except the home page
var menu=$("div.navMenu ul li a");
menu.click(function(){
var previous=window.location.hash;
var selected=$(this).attr("href");
if (previous != selected) {
$("div.page"+previous).fadeOut();
$("div.page"+selected).fadeIn();
}
$(this).addClass("selected");
menu.not(this).removeClass("selected");
});
menu.hover(function(){
$(this:not(.selected)).toggleClass("hover");
});
});
</script>
</head>
<body>
<div class="navMenu">
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#portfolio">Portfolio</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
<div class="page" id="home">This is my home page.</div>
<div class="page" id="portfolio">This is my portfolio page.</div>
<div class="page" id="contact">This is my contact page.</div>
</body>
</html>
Dreamweaver indicates that there is a syntax error in the line with
$(this:not(.selected)).toggleClass("hover");
However, I don't see what the syntax error is. (The idea is to toggle the "hover" class only for menu buttons which do not have the "selected" class). Any help would be greatly appreciated.