javascript $("#slider_range").slider 不是函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7567132/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 00:33:54  来源:igfitidea点击:

$("#slider_range").slider is not a function

javascriptjqueryjquery-uifirebugjquery-slider

提问by Gabriel

Ok, I have included the google api libraries for Jquery UI, like so:

好的,我已经包含了 Jquery UI 的 google api 库,如下所示:

<script type='text/javascript'  src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js' ></script>

Now I have a script that updates some spans and a hidden input on document slide and not only, on document ready:

现在我有一个脚本可以更新文档幻灯片上的一些跨度和隐藏输入,不仅是在文档就绪时:

<script type="text/javascript">
            $(document).ready(function()
            {
                 var slider=$('#slider_range').slider({
                        range:true,
                        min:0,
                        max:5,
                        step:1,
                        values:[0,3],
                        slide:function(event,ui)
                        {
                          $('#level').val(ui.values[0]+'-'+ui.values[1]);
                          $('#low').html(ui.values[0]);
                          $('#high').html(ui.values[1]);
                        }
                 });

                 var s=slider;
                 if(s.slider("values",0)==s.slider("values",1))
                 {
                    $('#level').val(s.slider("values",0));
                    $('#low').html(s.slider("values",0));
                    $('#high').html(s.slider("values",0));
                 }
                 else
                     {
                       $('#level').val(s.slider("values",0)+'-'+s.slider("values",1));
                       $('#low').html(s.slider("values",0));
                       $('#high').html(s.slider("values",1));
                     }
              });
         </script>

The ideea is that on a page it shows the slider and on another not. The error message I get from Firebug is this:

想法是在一个页面上显示滑块,而在另一个页面上不显示。我从 Firebug 得到的错误信息是这样的:

$("#slider_range").slider is not a function

And points to the line

并指向线

slide:function(event,ui)

What could be causing this? Why on a page the slider can be seen and on another (which uses the same template that loads the above) can`t?

什么可能导致这种情况?为什么在一个页面上可以看到滑块,而在另一个(使用加载上述内容的相同模板)上看不到?

Please help!

请帮忙!

回答by Gabriel

There were two differing jquery libraries included on the second page.

第二页包含两个不同的 jquery 库。

回答by patrics

I just had the same error while i used the foundation framework from zurb along with jquery ui slider.

当我使用 zurb 的基础框架和 jquery ui 滑块时,我遇到了同样的错误。

Problem #1: the foundation framework 3.2.4 already delivers jquery 1.8.1 and i tried to include my own copy of jquery 1.9 just before the foundation files. (= duplicate jquery inclusion)

问题 #1:基础框架 3.2.4 已经提供了 jquery 1.8.1,我试图在基础文件之前包含我自己的 jquery 1.9 副本。(= 重复的 jquery 包含)

Problem #2: the order of my inclusions. jquery ui needs to be included AFTER the foundation framework files.

问题 2:我的内含物的顺序。jquery ui 需要包含在基础框架文件之后。