Have had the same problem.
With jQuery UI's widget factory it is quite easy:
$.widget( "ui.pcntspinner", $.ui.spinner, {
_format: function(value) { return value + '%'; },
_parse: function(value) { return parseFloat(value); }
});
$("#spinner").pcntspinner({
min: 0,
max: 100,
step: .01 });
Demo: http://jsfiddle.net/aAHuT/
If integers are to be used '_parse' has to be adapted to use parseInt()
:
_parse: function(value) { return parseInt(value); }
The jQuery UI example for the Time Spinner has been very helpful for coming up with this solution.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…