首頁 > web前端 > js教程 > jQuery實作行動端滑桿拖曳選擇數位效果_javascript技巧

jQuery實作行動端滑桿拖曳選擇數位效果_javascript技巧

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
發布: 2016-05-16 15:23:50
原創
1651 人瀏覽過

本文為大家分享了基於jquery ui實現的一個精美實用的效果,可以透過滑鼠拖曳滑動效果來選擇數字,供大家參考,具體內容如下

運作效果圖:

實作程式碼:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

<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實作行動端滑桿拖曳選擇數字效果的程式碼,希望對大家的學習有所幫助。

相關標籤:
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板