简体   繁体   English

JQuery新手 - 无法显示滑块

[英]New to JQuery - Can't get a slider to show

I'm new to JQuery and want to use it to display a simple volume slider. 我是JQuery的新手,想用它来显示一个简单的音量滑块。

Can someone please point out my mistake? 有人可以指出我的错误吗?

Below is a minimal test code. 下面是一个最小的测试代码。 In case it matters, I'm using the JQuery v1.4.1 that comes with MVC2 如果它很重要,我正在使用MVC2附带的JQuery v1.4.1

Sample code: 示例代码:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>
        Multimedia
    </title>
    <script type="text/javascript" src="../../Scripts/jquery-1.4.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#volume").slider({
                orientation: "vertical",
                range: "min",
                min: 0,
                max: 100,
                step: 5,
                slide: function (event, ui) {
                    //do something;
                }
            });
        });

    </script>
</head>
<body>
    <div id="volume"></div>
</body>
</html>

This gives me the following error: 这给了我以下错误:

Error: $("#volume").slider is not a function
Source File: file:///c:/sample.html
Line: 15

It's worth noting that I can set the contents of #volume using .html and similar technique so it can find the element - just not the slider() function 值得注意的是,我可以使用.html和类似技术设置#volume的内容,以便它可以找到元素 - 而不是slider()函数

I'm testing in FF 3.6 我在FF 3.6中测试

Thanks in advance for any help 在此先感谢您的帮助

You need to include the jQuery UI JS file. 您需要包含jQuery UI JS文件。

Go to the downloads page and deselect everything, then select the slider. 转到下载页面并取消选择所有内容,然后选择滑块。 Doing that will also automatically select the sliders dependencies. 这样做也会自动选择滑块依赖项。 You can also choose a theme if you want. 如果需要,您也可以选择主题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM