Home > Web Front-end > JS Tutorial > Based on jquery, drag the mouse left and right to slide the slider with source code download_jquery

Based on jquery, drag the mouse left and right to slide the slider with source code download_jquery

WBOY
Release: 2016-05-16 15:23:55
Original
1712 people have browsed it

Before entering the main text, let me post a rendering to see if it is the effect you want:

Online demo Source code download

Based on jQuery mobile slider dragging setting code. This is a special effect that supports mobile phones. You can drag the slider range selector and drag the slider value selector.

No more nonsense, let me just post the code for you.

html code:

<div class="demo">
    <input type="hidden" class="single-slider" value="0" />
    <!-- <button id="g1">获取值</button> -->
  </div>
  <div class="demo">
    <input class="range-slider" type="hidden" value="10,89" />
    <!-- <button id="g2">获取值</button> -->
  </div> 
Copy after login

js code:

$(function () {
     $('.single-slider').jRange({
       from: 0,
       to: 100,
       step: 1,
       scale: [0, 25, 50, 75, 100],
       format: '%s',
       width: 300,
       showLabels: true,
       showScale: true
     });
     $('.range-slider').jRange({
       from: 0,
       to: 100,
       step: 1,
       scale: [0, 25, 50, 75, 100],
       format: '%s',
       width: 300,
       showLabels: true,
       isRange: true
     });
     $("#g1").click(function () {
       var aa = $(".single-slider").val();
       alert(aa);
     });
     $("#g2").click(function () {
       var aa = $(".range-slider").val();
       alert(aa);
     });
   });
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template