2012-08-09 6 views
3

저는 jquery와 html5를 처음 사용합니다.jquery를 사용하여 입력 유형, 범위의 입력 값, 최소값 및 최대 값을 변경하는 방법은 무엇입니까?

내 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]); 

    } 

I이 값이 자동으로 각각 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으로 어떻게 변경할 수 있습니까?

답변

7

입력 슬라이더의 값은 유효한 부동 소수점 숫자이어야합니다. 그래서 당신이 사용하고자하는 최대 최소값으로 작동하지 않을 것이라고 생각합니다.

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

그것이 here

+0

당신의 ANS가 정확하지만 값을 변경 작업을 참조하십시오 : 최소 및 최대 속성을 설정하는 jQuery 코드에 관해서

, 당신은 attribute 방법을 사용해야합니다. – Newbie

관련 문제