jQuery UI & Slider: Snap to increment

This entry is part 2 of 11 in the series jQuery UI Slider

jQuery UI Slider – Snap to increments

Increment slider values with the step option set to an integer, commonly a dividend of the slider’s maximum value.

The default increment is 1.

<!doctype html>
<html lang='en'>
<head>
    <meta charset='utf-8'>
    <title>jQuery UI Slider - Snap to increments</title>
    <link rel='stylesheet' href='//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css'>
    <script src='//code.jquery.com/jquery-1.10.2.js'></script>
    <script src='//code.jquery.com/ui/1.10.4/jquery-ui.js'></script>
    <link rel='stylesheet' href='https://codecrawl.com/code/jqueryui/jqueryui_style.css'>
    <script>
        $(function () {
            $('#slider').slider({
                value: 100,
                min: 0,
                max: 500,
                step: 50,
                slide: function (event, ui) {
                    $('#amount').val('$' + ui.value);
                }
            });
            $('#amount').val('$' + $('#slider').slider('value'));
        });
    </script>
</head>
<body>

<p>
    <label for='amount'>Donation amount ($50 increments):</label>
    <input type='text' id='amount' style='border:0; color:#f6931f; font-weight:bold;'>
</p>

<div id='slider'></div>

</body>
</html>
Try The Code Slider Widgets API Doc
Series Navigation<< jQuery UI & Slider: Basic slider
jQuery UI & Slider: Range with fixed maximum >>