Am using the script below for a sub nav on rollover which works fine but there is one thing i wold like to do and that is on a certain page i would like it to be visible!
in other words home page you rollover and sub nav is shown then when you click to a content page which has a subnav the sub nav mean is开发者_如何学Go be visible always shown and the over subnav are shown over the top on rolover.... if that makes scenes?
$(document).ready(function() {
$("ul#topnav li").hover(function() { //Hover over event on list item
$(this).find("div").show(); //Show the subnav
} , function() { //on hover out...
$(this).css({ 'background' : 'none'}); //Ditch the background
$(this).find("div").hide(); //Hide the subnav
});
});
the way iv made the pages is using a include file (inc.mainnav.php)
i was thinking of using somethink like .find.attr(class).cur .cur is the current nav page. but js is not that good...
hope some one can help ???
Give your current/active tab a class <li class="active">
and just have a css rule for
ul#topnav li.active div{display:block;}
it would be best to do it in css rather than JS
精彩评论