2015-04-16 50 views
-2

我有這個代碼here及以下...如何使用jquery流暢地顯示輸入範圍的值?

但如何使用jQuery來顯示輸入範圍的流利值?現在它可以工作,但不流利。感謝幫助。

JS:

$("#price").change(function() {      
    var newValue = $('#price').val(); 
    $("#valuePrice").html(newValue); 
    $('#block').css({'margin-left':+newValue}); 
}); 

HTML:

<div class="filterField"> 
<label>Price:</label> 
<input type="range" name="price" id="price" min="0" max="1000" value="3" /> 
<div class="rangeValue"><div id="valuePrice">3</div></div> 
</div> 
<div id="block"></div> 
+1

請添加代碼... –

+0

我的代碼是http://jsfiddle.net/BaEar/165/ ......我把它放到我的問題 – 1001001

+0

http://jsfiddle.net/BaEar/ 166/ –

回答

3

處理 「輸入」 事件:

$("#price").on("input", function() {      
... 
}); 
1

你可以使用鼠標移動

$("#price").on('change mousemove',function() {      
    var newValue = $(this).val(); 
    $("#valuePrice").html(newValue); 
    $('#block').css({'margin-left':+newValue}); 
}); 

SEE DEMO

相關問題