Javascript 平滑滚动和手风琴冲突引导

Javascript 平滑滚动和手风琴冲突引导,javascript,twitter-bootstrap,smooth-scrolling,Javascript,Twitter Bootstrap,Smooth Scrolling,虽然这已经被问了好几次了,但我还没有找到解决问题的方法 这是我的平滑滚动代码: $(function() { $('a[href*=#]:not([href=#]),a[href*=#]:not(a[data-toggle])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == th

虽然这已经被问了好几次了,但我还没有找到解决问题的方法

这是我的平滑滚动代码:

$(function() {
  $('a[href*=#]:not([href=#]),a[href*=#]:not(a[data-toggle])').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {

      var target = $(this.hash);
      target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
      if (target.length) {
        $('html,body').animate({
          scrollTop: target.offset().top
        }, 1000);
        return false;
      }
    }
  });
}); 
这是一个带有一些编辑的css技巧代码。 这是网站:

因此,手风琴仍然被选择用于滚动,并且它没有运行手风琴js。 我认为我的javascript非选择器代码存在问题:
a[href*=#]:不是(一个[数据切换])


感谢您的帮助:-]

您提供的页面代码有误:

$('a[href*=#]:not([href=#]),'a[href^="#"]:not([data-toggle])').click(function() {
                           ^^^ - extra and unnecessary character

这样,你的处理程序没有被设置。

< P>你也可以考虑指定应该触发平滑滚动动画的元素类(从而排除其他,例如手风琴标签),例如:

$('a[href*=#][class*="smooth"]:not([href=#])').click(function() 
反之亦然,指定不应触发脚本的元素类(在本例中,我们排除触发手风琴效果的链接类):


这就是你真正想要的:

$('a[href*="#"]:not([href="#"]):not([data-toggle])').click(function() {
    if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
        var target = $(this.hash);
        target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
        if (target.length) {
            $('html, body').animate({
                scrollTop: target.offset().top
            }, 1000);
            return false;
        }
    }
});
:不([数据切换]) 是为了避免使用引导选项卡、旋转木马等平滑滚动。

var headp=$(“.pixxett header”).innerHeight(); var stick=$(“.pixxett header.sticky”).innerHeight()

}))

切换:不([数据切换])
是完美的
$('a[href*="#"]:not([href="#"]):not([data-toggle])').click(function() {
    if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
        var target = $(this.hash);
        target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
        if (target.length) {
            $('html, body').animate({
                scrollTop: target.offset().top
            }, 1000);
            return false;
        }
    }
});
$(document).on('click', 'a[href^="#"]:not([href="#"]):not([data-toggle])', function (event) {
event.preventDefault();

if (scroll == 0){
    $('html, body').animate({
    scrollTop: $($.attr(this, 'href')).offset().top - stick}, 500);
}else{

$('html, body').animate({
    scrollTop: $($.attr(this, 'href')).offset().top - headp}, 500);
}