简单教程
提交运行
代码编辑器:
<!DOCTYPE html> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdn.bootcss.com/foundation/5.5.3/css/foundation.min.css"> <script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script> <script src="https://cdn.bootcss.com/foundation/5.5.3/js/foundation.min.js"></script> <script src="https://cdn.bootcss.com/foundation/5.5.3/js/vendor/modernizr.js"></script> <h2>显示滑块值</h2> <p>通过在 <code><div></code> 中添加 <code>data-options="display_selector:# **id** " </code>属性可以在滑块拖动时实时显示值</p> <p>需要注意的是:元素 id 值与滑块的 id 相同</p> <span id="mySlider"></span> <div class="range-slider" data-slider data-options="display_selector: #mySlider;"> <span class="range-slider-handle"></span> <span class="range-slider-active-segment"></span> </div> <!-- 初始化 Foundation JS --> <script> $(document).ready(function() { $(document).foundation(); }) </script>
运行结果: