jQuery 类型错误:$(...).slider 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26040459/
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
TypeError: $(...).slider is not a function
提问by gintech
Is there someway jquery slider dependent on server? I am using jquery library and Ui for jquery range slider. There is only one jquery library so i think no question on any conflict. The slider works perfectly fine in my linux server which gives correct output. But when i pushed the code is my IIS server i am getting this error which says TypeError: $(...).slider is not a function in mozilla browser and Uncaught TypeError: undefined is not a function in chrome browser. I am just wandering if server is anyway be the cause for it. :( Please suggest if anyone face something similar.
是否有某种方式依赖于服务器的 jquery 滑块?我正在将 jquery 库和 Ui 用于 jquery 范围滑块。只有一个 jquery 库,所以我认为没有任何冲突问题。滑块在我的 linux 服务器中工作得很好,可以提供正确的输出。但是当我推送代码是我的 IIS 服务器时,我收到这个错误,它说 TypeError: $(...).slider is not a function in mozilla browser and Uncaught TypeError: undefined is not a function in chrome browser。如果服务器无论如何是导致它的原因,我只是在徘徊。:(请建议是否有人面临类似的事情。
$(document).ready(function() {
$("#slider").slider({
range: "min",
animate: true,
value:0,
min: 0,
max: 30,
step: 1,
slide: function(event, ui) {
update(2,ui.value); //changed
}
});}
回答by Waqas Bukhary
Use both Jquery and ui, then it will work.
使用 Jquery 和 ui,然后它会工作。
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
回答by Jan Schnupp
I had the same error message. In the end it turned out that my code loaded jQuery twice, including a version of jQuery that was just too old. Once I made sure that only one, recent version of jQuery was linked into my code, the error went away.
我有同样的错误信息。最后发现我的代码加载了两次 jQuery,包括一个太旧的 jQuery 版本。一旦我确定只有一个最新版本的 jQuery 链接到我的代码中,错误就消失了。
Maybe one of your servers (the IIS server) is serving up an out of date version of jQuery?
也许您的其中一台服务器(IIS 服务器)正在提供过时版本的 jQuery?
So check what version of jQuery you are using. This one works fine for me:
因此,请检查您使用的是哪个版本的 jQuery。这个对我来说很好用:
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script>
回答by Tom Hammond
For me running rails you can individually specify which jQuery UI elements are listed and I didn't have slider in the pipeline. Adding that in fixed the problem!
对于运行 rails 的我,您可以单独指定列出哪些 jQuery UI 元素,而我在管道中没有滑块。添加它解决了问题!
回答by davefrassoni
Make 100% sure you are not including jquery.js lib twice or more.
确保 100% 不包含 jquery.js lib 两次或更多次。
Check inside other js packed files that you include in your page.
检查包含在页面中的其他 js 打包文件。