[英]Jquery knob animate
I am having trouble animating jquery knob. 我无法动画jquery旋钮。 As you can see in my example only the last one animates.
正如您在我的示例中所看到的,只有最后一个动画。
<input class="knob nummer1 animated" value="0" rel="64">
<input class="knob nummer2 animated" value="0" rel="77">
<input class="knob nummer3 animated" value="0" rel="99">
local $this
object was not getting set for every new instance of knob,instead same this
object was referenced each time. 当地
$this
对象没有得到对旋钮的每一个新的实例设置,而不是同this
对象每次都被引用。
so what you need to do is create a new local reference of this
object for every knob instance. 所以你需要做的是为每个旋钮实例创建一个
this
对象的新本地引用。
var $this = $(this);
Live Demo @ JSFiddle 现场演示@ JSFiddle
JS CODE: JS代码:
$('.knob').each(function() {
var $this = $(this);
var myVal = $this.attr("rel");
$this.knob({
});
$({
value: 0
}).animate({
value: myVal
}, {
duration: 2000,
easing: 'swing',
step: function() {
$this.val(Math.ceil(this.value)).trigger('change');
}
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.