Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery Scrollspy错误:激活了错误的导航项目_Jquery_Html_Css_Twitter Bootstrap_Scrollspy - Fatal编程技术网

Jquery Scrollspy错误:激活了错误的导航项目

Jquery Scrollspy错误:激活了错误的导航项目,jquery,html,css,twitter-bootstrap,scrollspy,Jquery,Html,Css,Twitter Bootstrap,Scrollspy,我正在使用scrollspy处理引导登录页: // ScrollSpy $('body').scrollspy({ target: '' }); $('[data-spy="scroll"]').each(function () { var $spy = $(this).scrollspy('refresh') }); 但是,它没有正确地突出显示当前的导航项目,而是突出显示下一个或下一个但只有一个项目。是什么引起了这个错误?我怎样才能阻止它 出现错误的站点是。您需要添加如下目标: $(

我正在使用scrollspy处理引导登录页:

// ScrollSpy
$('body').scrollspy({ target: '' });
$('[data-spy="scroll"]').each(function () {
    var $spy = $(this).scrollspy('refresh')
});
但是,它没有正确地突出显示当前的导航项目,而是突出显示下一个或下一个但只有一个项目。是什么引起了这个错误?我怎样才能阻止它


出现错误的站点是。

您需要添加如下目标:

$('body').scrollspy({ target: '.navbar-example' })
这一切都在书中解释过了

对于一般引导安装:

将scrollspy行为添加到顶栏导航中,将data spy=滚动添加到要监视的元素(通常是主体)。然后使用任何Bootstrap.nav组件的父元素的ID或类添加数据目标属性


查看data attr文档中的示例。

感谢您提供的信息:我找不到任何解释,目标参数发生了什么变化。不,这并没有解决问题。还是一样的行为。