Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.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 - Fatal编程技术网

Javascript 未捕获类型错误:不是函数

Javascript 未捕获类型错误:不是函数,javascript,jquery,Javascript,Jquery,我已经修改了我在网上找到的小提琴,并想在我的网页上运行它。然而,当我尝试这样做时,我得到了一个未捕获的类型错误。你能帮我解决这个问题吗 链接到我的页面: 链接到JSFIDLE: 已经谢谢你了 这是我的密码: var sliders = $("#sliders .slider"); sliders.each(function() { var value = parseInt($(this).text(), 10), availableTotal = 100; $(thi

我已经修改了我在网上找到的小提琴,并想在我的网页上运行它。然而,当我尝试这样做时,我得到了一个未捕获的类型错误。你能帮我解决这个问题吗

链接到我的页面: 链接到JSFIDLE:

已经谢谢你了

这是我的密码:

var sliders = $("#sliders .slider");

sliders.each(function() {
    var value = parseInt($(this).text(), 10),
    availableTotal = 100;

    $(this).empty().slider({
        value: 0,
        min: 0,
        max: 100,
        range: "max",
        step: 10,
        animate: 100,
        slide: function(event, ui) {
            // Update display to current value
            $(this).siblings().text(ui.value + ' %');

            // Get current total
            var total = 0;

            sliders.not(this).each(function() {
                total += $(this).slider("option", "value");
            });

            // Need to do this because apparently jQ UI
            // does not update value until this event completes
            total += ui.value;

            var max = availableTotal - total;

            // Update each slider
            sliders.not(this).each(function() {
            var t = $(this),
                value = t.slider("option", "value");

            t.slider("option", "max", max + value)
                .siblings().text(value + ' %');
            t.slider('value', value);
            });
        }
    });
});

必须包含定义滑块函数的JS文件。
也许,来自jQueryUI

  <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
  <script src="//code.jquery.com/jquery-1.10.2.js"></script>
  <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  <link rel="stylesheet" href="/resources/demos/style.css">


这是您缺少的
jqueryui.js
库。只需添加以下内容:

<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>


缺少滑块插件引用!谢谢你的意见。你能详细说明一下吗?它在这里起作用:如果您可以看到左侧的框架和扩展以及外部资源选项卡,则包括
jqueryui
。您的代码中没有。非常感谢您的帮助。我想在每次滑块更改时将每个值的值输出到控制台。你能帮我加上这个吗?谢谢非常感谢你!!我正在尝试使用您的建议,在每次更新滑块时在3个不同的字段中插入值。但是,我需要知道哪个滑块给出了哪些值。我是否可以通过任何方式获得更改的滑块的编号/名称,以便将值放入正确的字段?希望它有意义。。我试图使用console.log(jQuery(this.index());要输出滑块的索引,但无法使其工作:-)升级演示。请参阅console.log($(this.parents().attr('class'))如果您对答案满意,可以将我的答案标记为已接受吗?当然再次感谢!但我看不到演示中有任何变化?:-)