JQuery spinner not to reset the value according to the step

444 views Asked by At

On jquery spinner, I want the size of the step to be 5, but I want to keep the initial value as 1 and then it should increment 5, so the next value should be 6, and then 11, and so on. But when defining step, its ignoring the initial value and taking it as 5 and then 10 and so on. my code is :

$(".square-off-ticks-count").val(1).spinner({
        step:5,
        disabled: true,
        spin: function(e,ui){
            if ( ui.value >  96) {
                $( this ).spinner( "value", 1);
                return false;
            } else if ( ui.value < 1 ) {
                $( this ).spinner( "value", 96 );
                return false;
            }
        }
    });

I want the max value to be 96. Please help.

1

There are 1 answers

1
Kiers_M On

I think you can set the min / max in the initial configuration too, so you'd probably not need the spin function.

Try this:

$(".square-off-ticks-count").spinner({
    step:5,
    min:1,
    max:96
});