jQuery Mobile - Form Slider Controls



Description

Slider allows you to choose a numeric value from a range of values. Slider provides you a handle to slide and select a value.

Example

Following example demonstrates the use of form slider control in jQuery Mobile.

<!DOCTYPE html>
<html>
   <head>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
      <script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
      <script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
   </head>
   
   <body>
      <div data-role = "page">
         <div data-role = "header">
            <h2>Form Multiple Selection</h2>
         </div>
         
         <div data-role = "main" class = "ui-content">
            <form method = "POST" action = "sliderdemo.php">
               <label for = "slider1">Simple Slider</label>
               <input type = "range" name = "slider1" id = "slider1" min = "0" max = "100" value = "60">

               <label for = "range-1">Show Value:</label>
               <input type = "range" name = "range-1" id = "range-1" min = "0" max = "100" value = "20" data-show-value = "true">

               <label for = "range-2">Popup Value:</label>
               <input type = "range" name = "range-2" id = "range-2" min = "0" max = "100" value = "60" data-popup-enabled = "true">

               <label for = "range-3">Highlight slider:</label>
               <input type = "range" name = "range-3" id = "range-3" min = "0" max = "100" value = "30" data-highlight = "true">

               <input type = "submit" value = "Submit" name = "submit" data-inline = "true">
            </form>
         </div>
      </div>
      
   </body>
</html>

Output

Let's carry out the following steps to see how the above code works −

  • Save the above html code as form_slider_controls.html file in your server root folder.

  • Open this HTML file as http://localhost/form_slider_controls.html and the following output will be displayed.

jquery_mobile_forms.htm
Advertisements