jQuery 滑块未知
这个滑块是如何工作的?
http://jqueryui.com/demos/slider
给出的源没有显示
<style>
#demo-frame > div.demo { padding: 10px !important; }
</style>
<script>
$(function() {
$( "#slider" ).slider();
});
</script>
<div class="demo">
<div id="slider"></div>
</div><!-- End demo -->
我在添加此之前包含 jquery 的
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
任何内容但它给了我
SCRIPT438:对象不支持属性或方法“滑块”
错误。
这就是整个代码的样子
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<style>
#demo-frame > div.demo { padding: 10px !important; }
</style>
<div class="demo">
<div id="slider"></div>
</div><!-- End demo -->
<script>
$(function() {
$( "#slider" ).slider();
});
</script>
</body>
</html>
我错过了什么?
How does this slider work?
http://jqueryui.com/demos/slider
source given shows up nothing
<style>
#demo-frame > div.demo { padding: 10px !important; }
</style>
<script>
$(function() {
$( "#slider" ).slider();
});
</script>
<div class="demo">
<div id="slider"></div>
</div><!-- End demo -->
I did include jquery before adding this
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
but it gives me
SCRIPT438: Object doesn't support property or method 'slider'
error.
This is what entire code looks like
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<style>
#demo-frame > div.demo { padding: 10px !important; }
</style>
<div class="demo">
<div id="slider"></div>
</div><!-- End demo -->
<script>
$(function() {
$( "#slider" ).slider();
});
</script>
</body>
</html>
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您确实包含了 jQuery...但是您使用的是
jQuery ui
插件方法 -.slider()
而不引用 ui 插件。因此,该方法
slider
对于 javascript 来说是未知的,请在 jQuery 库之后添加引用:
更新:
花费了太多时间后,我发现你的问题,你缺少JQuery ui css:
JSFiddle DEMO
You did include jQuery... but you are using
jQuery ui
plugin method-.slider()
without referencing the ui plugin.So that method
slider
is unknown to javascript,Add the reference after the jQuery library:
Update:
After too much time spent, I've found your problem, you're missing the JQuery ui css:
JSFiddle DEMO
您应该使用 jQuery UI 作为滑块。
<脚本 src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"/>
You should be using jQuery UI for the slider.
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"/>
由于它是一个 jQuery UI 滑块,因此您缺少需要包含在 jQuery 之后的 jQuery UI 。
Since it's a jQuery UI Slider, you are missing jQuery UI which needs to be included after jQuery.