这是我的脚本:
$(document).ready(function(){
    $(".slideToggle").click(function(e) {   
       e.preventDefault();
       $(".top-menu li").removeClass("active");
       var $more = $("#impressum").slideToggle("slow");
       $("body,html").animate({
           scrollTop: $more.offset().top
    }, {
        duration: 1100,
        queue: false
    })
    });
});
当我单击具有类 slideToggle 的锚点时,它会打开印记 div。到目前为止,一切都很好。但是该事件$(".top-menu li").removeClass("active");没有被执行。我不知道为什么。一旦我删除了 slideToggle 函数,上面的事件就会起作用。但我不能在点击功能上结合这两个事件。
你能帮我吗?提前致谢!
编辑:似乎脚本与我正在使用的另一个脚本发生冲突:
$(document).ready(function() {
$("a.anchorLink").anchorAnimate()
// Cache selectors
var topMenu = $(".top-menu"),
    topMenuHeight = topMenu.outerHeight()+15,
    // All list items
    menuItems = topMenu.find("a.anchorLink"),
    // Anchors corresponding to menu items
    scrollItems = menuItems.map(function(){
      var item = $($(this).attr("href"));
      if (item.length) { return item; }
    });
// Bind to scroll
$(window).scroll(function(){
   // Get container scroll position
   var fromTop = $(this).scrollTop()+topMenuHeight;
   // Get id of current scroll item
   var cur = scrollItems.map(function(){
     if ($(this).offset().top < fromTop)
       return this;
   });
   // Get the id of the current element
   cur = cur[cur.length-1];
   var id = cur && cur.length ? cur[0].id : "";
   // Set/remove active class
   menuItems
     .parent().removeClass("active")
     .end().filter("[href=#"+id+"]").parent().addClass("active");
});
});
因为如果我删除这个脚本,另一个脚本就可以工作。错误在哪里?