javascriptjqueryhtmlcss

HTML5 Input type Range with min value slider, max value slider, and ticks


I have to implement HTML5 input type Range

<input type="range"  min="0" max="100" step="10"  value="40" />

Now i want to show ticks on steps just like on image attached. Is it possible ? Is there any way ?

Sample Image


Solution

  • Implement this with HTML5's input type Range is not possible because it accept only one input

    you can achieve this by using JQUERY slider check this

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>slider</title>
      <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
      <link rel="stylesheet" href="/resources/demos/style.css">
      <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
      <script>
      $( function() {
        $( "#slider-range" ).slider({
          range: true,
          min: 0,
          max: 500,
          values: [ 75, 300 ],
          slide: function( event, ui ) {
            $( "#amount" ).val( "₹" + ui.values[ 0 ] + " - ₹" + ui.values[ 1 ] );
          }
        });
        $( "#amount" ).val( "₹" + $( "#slider-range" ).slider( "values", 0 ) +
          " - ₹" + $( "#slider-range" ).slider( "values", 1 ) );
      } );
      </script>
    </head>
    <body>
     
    <p>
      <label for="amount">Price range:</label>
      <input type="text" id="amount" readonly style="border:0; color:#f6931f; font-weight:bold;">
    </p>
     
    <div id="slider-range"></div>
     
     
    </body>
    </html>