需求,实现同音量大小控制的拖拽效果。网上搜了一下使用bootstrap可以实现。代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery Bootstrap Slider Plugin Examples</title>
<link rel="stylesheet" href="../../css/bootstrap.min.css">
<link href="../../css/bootstrap-slider.css" rel="stylesheet" type="text/css">
</head>
<body >
<div class="container">
<h2>Custom tick marks.</h2>
<input id="ex4" type="text" data-slider-ticks="[0, 100, 200, 300, 400,500,600,700]" data-slider-ticks-snap-bounds="30"
data-slider-ticks-labels='["1", "2", "3", "4", "5","6","7","8","9"]'/>
</div>
<script src="../../js/jquery.min.js"></script>
<script src="../../js/bootstrap.min.js"></script>
<script src="../../js/bootstrap-slider.js"></script>
<script>
$("#ex4").slider({
ticks: [0, 100, 200, 300, 400,500,600,700,800],
ticks_labels: ['1', '2', '3', '4', '5','6', '7', '8', '9'],
ticks_snap_bounds: 100
});
</script>
</body>
</html>
</pre><pre>
实现效果;
ticks_labels显示的就是每一个刻度的label。
引用的文件地址可以去云盘下载:https://pan.baidu.com/s/1MEsc2
推荐一下相关的网站:http://www.jqueryscript.net/form/Highly-Customizable-Range-Slider-Plugin-For-Bootstrap-Bootstrap-Slider.html
http://demos.jquerymobile.com/1.3.0/docs/widgets/sliders/