javascript - Input number section function only works one time -


i have 1 function number input box come + , - button on sides, , copy code in shopify theme use. function show 1 time. need apply product offers.

(function ($) {    $.fn.bootstrapnumber = function (options) {      var settings = $.extend({         upclass: 'default',         downclass: 'default',         center: true     }, options);      return this.each(function (e) {         var self = $(this);         var clone = self.clone();          var min = self.attr('min');         var max = self.attr('max');          function settext(n) {             if ((min && n < min) || (max && n > max)) {                 return false;             }              clone.focus().val(n);             return true;         }          var group = $("<div class='input-group'></div>");         var down = $("<button type='button'>-</button>").attr('class', 'btn btn-' + settings.downclass).click(function () {             settext(parseint(clone.val()) - 1);         });         var = $("<button type='button'>+</button>").attr('class', 'btn btn-' + settings.upclass).click(function () {             settext(parseint(clone.val()) + 1);         });         $("<span class='input-group-btn'></span>").append(down).appendto(group);         clone.appendto(group);         if (clone) {             clone.css('text-align', 'center');         }         $("<span class='input-group-btn'></span>").append(up).appendto(group);          // remove spins original         clone.prop('type', 'text').keydown(function (e) {             if ($.inarray(e.keycode, [46, 8, 9, 27, 13, 110, 190]) !== -1 ||                 (e.keycode == 65 && e.ctrlkey === true) ||                 (e.keycode >= 35 && e.keycode <= 39)) {                 return;             }             if ((e.shiftkey || (e.keycode < 48 || e.keycode > 57)) && (e.keycode < 96 || e.keycode > 105)) {                 e.preventdefault();             }              var c = string.fromcharcode(e.which);             var n = parseint(clone.val() + c);              //if ((min && n < min) || (max && n > max)) {             //    e.preventdefault();             //}         });          clone.prop('type', 'text').blur(function (e) {             var c = string.fromcharcode(e.which);             var n = parseint(clone.val() + c);             if ((min && n < min)) {                 settext(min);             }             else if (max && n > max) {                 settext(max);             }         });           self.replacewith(group);     });   }; }(jquery)); 

how initialise function ?

your problem lies there... because works using this:

$('input').bootstrapnumber(); 

see fiddle includes exact unmodified script.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -