먼저 감지 : 당신은 내가 $(item).attr('min') && $(item).attr('min')
접근 방식으로 가야했다 input[type=range]
선택기를 사용할 수 없기 때문에
$('input').each(function (i, item) {
if ($(item).attr('min') !== undefined && $(item).attr('max') !== undefined) {
var select = document.createElement("SELECT");
$(select).attr('name', $(item).attr('name'));
$(select).attr('id', $(item).attr('id'));
$(select).attr('disabled', $(item).attr('disabled'));
var step = 1;
if ($(item).attr('step') !== undefined) {
step = parseFloat($(item).attr('step'));
}
var min = parseFloat($(item).attr('min'));
var max = parseFloat($(item).attr('max'));
var selectedValue = $(item).attr('value');
for (var x = min; x <= max; x = x + step) {
var option = document.createElement("OPTION");
$(option).text(x).val(x);
if (x == selectedValue) { $(option).attr('selected', 'selected'); }
$(select).append(option);
};
$(item).after(select);
$(item).remove();
}
});
을,이 조금 이상한 얻을 것이다 이 두 속성을 가진 다른 유형의 입력 컨트롤이있는 경우
나는 그것을 좋아한다. 아마도''jQuery.support.rangeInput = ((jQuery.browser.safari) || (jQuery.browser.opera && jQuery.browser.version> = 2.0))'와 같이 범위 입력 지원을 확인 하시겠습니까? –
코드 풀어 주셔서 고마워요 :) –
우아하지 않은 점진적인 향상을 선호 했으므로 브라우저에서 '를 지원하지 않으며 자바 스크립트를 사용할 수 없으므로 입력 결코 개종하지 않을 것이다. 아직도, 적어도 질문에 답합니다. –