ASA
ASA

Reputation: 13

How to add tick marks and labels to jquery mobile slider?

On my horizontal slider I want to show tick marks at regular intervals say 0,20,40,60,80 and 100. Also I want to display these values as labels below the slider. I know it can be done easily using jquery UI sliders but I am using Jquery mobile slider and didn't find any option to do so.

Upvotes: 1

Views: 1137

Answers (1)

msapkal
msapkal

Reputation: 8346

Hope this helps you.

HTML

<form class="full-width-slider">
    <label for="slider-12" class="ui-hidden-accessible">Slider:</label>
    <input type="range" name="slider-12" id="slider-12" min="0" max="100" value="0" step="20"/>
    <label id="slider-value">0</label>
</form>

CSS

/* Hide the number input */

.full-width-slider .ui-slider-track {
    margin-left: 15px;
}

.full-width-slider input.ui-slider-input {
    display: none;
}

JS

$( "#slider-12" ).slider().change(function() {
    $('#slider-value').text($('#slider-12').val());
});

DEMO

Upvotes: 1

Related Questions