Reputation: 5250
I am having trouble animating jquery knob. 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">
Upvotes: 3
Views: 4562
Reputation: 6002
local $this
object was not getting set for every new instance of knob,instead same this
object was referenced each time.
so what you need to do is create a new local reference of this
object for every knob instance.
var $this = $(this);
JS CODE:
$('.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');
}
});
});
Upvotes: 5