jQuery spinner - Change value on spin event

Jason Lipo picture Jason Lipo · Oct 20, 2013 · Viewed 7.3k times · Source

I want to be able to append text to the spinner on the 'spin' event. Here is what I currently have, but nothing is happening.

$( "#obj1, #obj2" ).spinner({
    min: 0,
    step: 5,
    spin: function( event, ui ) {
        $("#" + event.target.id).spinner("value", "Number " + ui.value);
    }
});

Anyone know what I'm doing wrong?

Answer

bancer picture bancer · Apr 25, 2017

Only with return false; worked for me:

$('#obj1').spinner({
        min: 2,
        max: 10,
        spin: function(event, ui) {
              $(this).spinner('option', 'min', 0);
              $(this).spinner('value', 0);
              $(this).spinner('option', 'min', 2);
              return false;
        }
});