[英]NaN Jquery knob
我试图删除显示在我的jquery旋钮上的NaN。 我尝试了一些操作,例如设置超时和调整倒数计时器。 如何固定旋钮,使其在首次调用时不再显示NaN?
范例http://codepen.io/missile20706/pen/jAaYjx
$.fn.timer = function( userdefinedoptions ){
var $this = $(this), opt, count = 0;
opt = $.extend( {
// Config
'timer' : 30, // 300 second default
'width' : 100 ,
'height' : 100 ,
'fgColor' : "blue" ,
'bgColor' : "white"
}, userdefinedoptions
);
$this.knob({
'min':0,
'max': opt.timer,
'readOnly': true,
'width': opt.width,
'height': opt.height,
'fgColor': opt.fgColor,
'bgColor': opt.bgColor,
'displayInput' : true,
'dynamicDraw': false,
'ticks': 0,
'thickness': 0.3
});
setInterval(function(){
newVal = ++count;
$this.val(newVal).trigger('change');
}, 1000);
};
$('.example').timer();
只需将输入的初始值设置为“ 0”
<input class="example" value="0">
未设置输入的初始值,这会导致此问题。 您可以在html中添加value属性(如发布的答案所建议),或更改js函数进行设置。 喜欢
$.fn.timer = function( userdefinedoptions ){
var $this = $(this), opt, count = 0;
$(this).val(0);
opt = $.extend( { ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.