HTML5输入类型带有最小值滑块,最大值滑块和刻度的范围 [英] HTML5 Input type Range with min value slider, max value slider, and ticks
本文介绍了HTML5输入类型带有最小值滑块,最大值滑块和刻度的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须实现HTML5输入类型范围
I have to implement HTML5 input type Range
<input type="range" min="0" max="100" step="10" value="40" />
现在,我想在步幅上显示刻度线,就像所附的图像一样.是否有可能 ?有什么办法吗?
Now i want to show ticks on steps just like on image attached. Is it possible ? Is there any way ?
推荐答案
无法使用HTML5的输入类型Range
来实现此功能,因为它仅接受一个输入
Implement this with HTML5's input type Range
is not possible because it accept only one input
您可以使用JQUERY滑块检查此情况
you can achieve this by using JQUERY slider check this
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>slider</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#slider-range" ).slider({
range: true,
min: 0,
max: 500,
values: [ 75, 300 ],
slide: function( event, ui ) {
$( "#amount" ).val( "₹" + ui.values[ 0 ] + " - ₹" + ui.values[ 1 ] );
}
});
$( "#amount" ).val( "₹" + $( "#slider-range" ).slider( "values", 0 ) +
" - ₹" + $( "#slider-range" ).slider( "values", 1 ) );
} );
</script>
</head>
<body>
<p>
<label for="amount">Price range:</label>
<input type="text" id="amount" readonly style="border:0; color:#f6931f; font-weight:bold;">
</p>
<div id="slider-range"></div>
</body>
</html>
这篇关于HTML5输入类型带有最小值滑块,最大值滑块和刻度的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文