开发者

Horizontal Subnav jquery

开发者 https://www.devze.com 2023-03-16 14:59 出处:网络
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!

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号