欢迎来到代码驿站!

JavaScript代码

当前位置:首页 > 网页前端 > JavaScript代码

jQuery实现移动端滑块拖动选择数字效果

时间:2021-06-15 09:13:24|栏目:JavaScript代码|点击:

本文为大家分享了基于jquery ui实现的一个精美实用的效果,可以通过鼠标拖拽滑动效果来选择数字,供大家参考,具体内容如下

运行效果图:

实现代码:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="gb2312">
<title>demo</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<style>
 .slider-box{ background:#F0EFEB; font-family:Microsoft Yahei; padding-bottom:10px}
 .slider-box .item{ padding:10px}
 .slider-box .item .tag, .slider-box .item .slider, .slider-box .item .val{ float:left; margin-right:18px}
 .slider-box .item .slider{ width:400px}
 .slider-box .item .slider div{ background:#8FBF0B; border:none; height:0.5em; margin-top:0.5em}
 .slider-box .item .slider div .ui-slider-handle{ background:#F4F3F1; width:1em; height:1em; border-radius:1em}
 .slider-box .item .val input{ border:none; border-bottom:1px solid #ABADA8; background:none; padding:0.1em 1em; color:#E4531C; font-weight:bold; font-size:1em; width:5em; text-align:center}
 .clr{ clear:both}
</style>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
</head>
<body>
 <div class="slider-box">
 <div class="item">
 <div class="tag">骑行里程:</div>
 <div class="slider">
 <div id="budget"></div>
 </div>
 <div class="val"><input value="8800" name="budget" /></div>
 </div>
 <div class="clr"></div>
 <div class="item">
 <div class="tag">骑行天数:</div>
 <div class="slider">
 <div id="days"></div>
 </div>
 <div class="val"><input value="9" name="days" /></div>
 </div>
 <div class="clr"></div>
 </div>
 <script>
 $("#budget").slider({
 min: 2000,
 max: 17000,
 step: 100,
 value: $('input[name="budget"]').val(),
 slide: function( event, ui ) {
 $('input[name="budget"]').val(ui.value)
 }
 });
 $("#days").slider({
 min: 1,
 max: 20,
 value: $('input[name="days"]').val(),
 slide: function( event, ui ) {
 $('input[name="days"]').val(ui.value)
 }
 });
 </script>
</body>
</html>

以上就是jQuery实现移动端滑块拖动选择数字效果的代码,希望对大家的学习有所帮助。

上一篇:Bootstrap Table从零开始

栏    目:JavaScript代码

下一篇:JavaScript实现点击出现子菜单效果

本文标题:jQuery实现移动端滑块拖动选择数字效果

本文地址:http://www.codeinn.net/misctech/142004.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有