Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/396.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/svn/5.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
Javascript 滚动到返回错误_Javascript_Jquery_Twitter Bootstrap_Collapse_Scrollto - Fatal编程技术网

Javascript 滚动到返回错误

Javascript 滚动到返回错误,javascript,jquery,twitter-bootstrap,collapse,scrollto,Javascript,Jquery,Twitter Bootstrap,Collapse,Scrollto,我正在使用引导在我的站点中创建一个可折叠的元素。我目前有一个按钮,可以切换可折叠元素,但可折叠元素在页面上的位置较低,因此,如果只单击该按钮,您可能不会注意到任何更改,具体取决于浏览器窗口的大小。这会造成糟糕的用户体验,所以我想让窗口向下滚动,以新显示的元素为中心。我的脚本如下所示: $("#about-collapse").on("show.bs.collapse", function () { var selected = $(this); var collapseh = $(".

我正在使用引导在我的站点中创建一个可折叠的元素。我目前有一个按钮,可以切换可折叠元素,但可折叠元素在页面上的位置较低,因此,如果只单击该按钮,您可能不会注意到任何更改,具体取决于浏览器窗口的大小。这会造成糟糕的用户体验,所以我想让窗口向下滚动,以新显示的元素为中心。我的脚本如下所示:

$("#about-collapse").on("show.bs.collapse", function () {

  var selected = $(this);
  var collapseh = $(".collapse .in").height();

  $.scrollTo(selected, 500, {
    offset: -(collapseh)
  });
});
每次单击以显示元素时,我的浏览器都会返回错误:

Uncaught TypeError: Object function ( selector, context ) {
    // The jQuery object is actually just the init constructor 'enhanced'
    return new jQuery.fn.init( selector, context, rootjQuery );
} has no method 'scrollTo' 

这里发生了什么?

如果您真的想使用toScroll(平滑滚动)


我只建议使用:它非常容易使用,比引导更容易使用。您与JQuery和页面上加载的另一个脚本有冲突。您需要做以下两件事之一:

  • 逐个删除其他脚本,直到找到有问题的脚本为止

  • 将jQuery从使用美元符号更改为非冲突变量:

  • 
    //告诉它有什么东西在用美元符号
    $.noConflict();
    //现在不用美元符号,而是使用“jQuery”
    jQuery(文档).ready(函数($){
    //使用jQuery的$的代码如下所示。
    });
    
    插件是否丢失了!?隐马尔可夫模型。。。我喜欢这个想法,但现在我返回一个单独的错误,我的冲突脚本无法运行。此外,滚动仍无法执行。未捕获的TypeError:对象[object]的属性“$”不是function@Dig_Dig_Dig这是因为您仍然在某处使用
    $
    (在您的脚本中或包含的脚本中)。
    <script>
        //Tell it something else is using the dollar sign
        $.noConflict();
    
        //Now instead of using the dollar sign, you use "jQuery"
        jQuery( document ).ready(function( $ ) {
            // Code that uses jQuery's $ can follow here.
        });