(function ($) { $.fn.niceNumber = function(options) { var settings = $.extend({ autoSize: true, autoSizeBuffer: 1, buttonDecrement: '-', buttonIncrement: "+", buttonPosition: 'around' }, options); return this.each(function(){ var currentInput = this, $currentInput = $(currentInput), attrMax = null, attrMin = null; // Handle max and min values if ( typeof $currentInput.attr('max') !== typeof undefined && $currentInput.attr('max') !== false ) { attrMax = parseFloat($currentInput.attr('max')); } if ( typeof $currentInput.attr('min') !== typeof undefined && $currentInput.attr('min') !== false ) { attrMin = parseFloat($currentInput.attr('min')); } // Fix issue with initial value being < min if ( attrMin && !currentInput.value ) { $currentInput.val(attrMin); } // Generate container var $inputContainer = $('
',{ class: 'nice-number' }) .insertAfter(currentInput); // Generate interval (object so it is passed by reference) var interval = {}; // Generate buttons var $minusButton = $('