【问题标题】:jQuery UI Slider on Multiple Inputs not working多个输入上的 jQuery UI 滑块不起作用
【发布时间】:2013-06-21 10:37:24
【问题描述】:

我有点卡住,想知道是否有人能发现原因?它实际上根本没有生成滑块,所以有点丢失。

这里的JSFiddle:http://jsfiddle.net/DmDkp/

HTML

<div class="markup scoreSlide">
    <input type="text" id="" class="scoreID" value="" />
    <div class="scoreSlider"></div> 
</div>

<div class="markup scoreSlide">
    <input type="text" id="" class="scoreID" value="" />
    <div class="scoreSlider"></div> 
</div>

<div class="markup scoreSlide">
    <input type="text" id="" class="scoreID" value="" />
    <div class="scoreSlider"></div> 
</div>

JS

jQuery(document).ready(function() {
    jQuery('.scoreSlide').each(function(){
        jQuery(this).find('.scoreID').slider({
            animate: true,
            range: "min",
            value: value: jQuery('.scoreID').val(),
            min: 1,
            max: 5,
            step: 1,
            slide: function(event, ui) {
             jQuery(this).find('.scoreSlider').html(ui.value);
            },
        });
    });
});

【问题讨论】:

  • 这是什么? value: value: jQuery('.scoreID').val(),

标签: jquery jquery-ui jquery-ui-slider


【解决方案1】:
jQuery(this).find('.scoreSlider').slider({
            animate: true,
            range: "min",
            value: jQuery('.scoreSlider').val(),
            min: 1,
            max: 5,
            step: 1,
            slide: function(event, ui) {
             jQuery(this).find('.scoreID').html(ui.value);
            },
        });

演示-- &gt;http://jsfiddle.net/DmDkp/8/

要在文本框中获取值,请执行以下操作:

slide: function(event, ui) {
            $(this).parent().find('.scoreID').val(ui.value);
 }

【讨论】:

  • 也许我弄错了,滑块应该在输入下方?但似乎不是。
  • 我在这里再次更新:jsfiddle.net/DmDkp/5 并更改滑块以更改但不更新值,您知道为什么吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多