我在页眉和页脚导航上有一个主导航。但我只会在Header和页脚导航上有主导航功能。但如果推出页脚导航,主导航“红线”悬停效果不起作用,因为主页导航与页脚导航有关,我不知道是什么问题..
我的Testsite:
http://topkosmetikstudios.de/release/index.php?article_id=1
这里是我的javascript代码:
function header_menu_line() {
"use strict";
var $el, leftPos, newWidth;
$("#magic-line").remove();
$("#main_menu").append("<li id='magic-line'></li>");
var $magicLine = $("#magic-line");
$magicLine
.width($(".current_menu_ancestor").width())
.css("left", $(".current_menu_ancestor a").position().left)
.data("origLeft", $magicLine.position().left)
.data("origWidth", $magicLine.width());
$("#main_menu > li").hover(function() {
$el = $(this).find("a");
leftPos = $el.position().left;
newWidth = $el.parent().width();
$magicLine.stop().animate({
left: leftPos,
width: newWidth
}, 300);
}, function() {
$magicLine.stop().animate({
left: $magicLine.data("origLeft"),
width: $magicLine.data("origWidth")
}, 300);
});
}
答案 0 :(得分:1)
我会检查你的目标.current_menu_ancestor,你也在页脚中使用该类,并且你没有专门针对标题;可能会抛出它的东西。