【问题标题】:How to change the input values, min value and max value in the input type=range using jquery?如何使用jquery更改输入类型=范围中的输入值、最小值和最大值?
【发布时间】:2012-08-09 23:17:14
【问题描述】:

我是 jquery 和 html5 的新手。

我的 jquery 是:

var A_Route=['A1','A2','A3',.....'A50'];
var counter=0;
$("input[name='radio-choice']").change(function(){
    if ($(this).val() == "on")
    {
        $('#slider').val(A_Route[counter]);

    }

当我选择一个值为 ON 的单选按钮时,滑块的最小值和最大值应自动分别变为 A1 和 A50。当我滑过滑块时,我的值应该从 A1 变为 A50。

我的 HTML 是:

<div data-role="fieldcontain">
                <fieldset data-role="controlgroup" data-type="horizontal">
                    <legend>Layout view:</legend>
                          <input type="radio" name="radio-choice" id="radio-choice-c" value="on" checked="checked" />
                          <label for="radio-choice-c">List</label>
                          <input type="radio" name="radio-choice" id="radio-choice-d" value="off" />
                          <label for="radio-choice-d">Grid</label>
                          <input type="radio" name="radio-choice" id="radio-choice-e" value="other" />
                          <label for="radio-choice-e">Gallery</label>
                            </fieldset>
           </div>

<div data-role="fieldcontain">
        <label for="slider">Room:</label>
        <input type="range" name="slider" id="slider" value="--------" min=? max=? data-highlight="true"  />
</div>

您认为最小和最大代码应该是多少?和 如何将输入值从 A1 更改为 A50?

【问题讨论】:

    标签: jquery html


    【解决方案1】:

    输入滑块的值只能是任何有效的浮点数。所以我认为它不适用于您要使用的最小最大值。

    关于设置 min 和 max 属性的 jQuery 代码,您应该使用 attribute 方法:

        $('#slider').attr('min', A_Route[0]);
        $('#slider').attr('max', A_Route[3]);
    

    看到它在工作here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-22
      • 1970-01-01
      • 2020-08-27
      • 1970-01-01
      相关资源
      最近更新 更多