大家好我花了好几个小时试图解决这个小问题,我想用这个jQuery knob在每个点触发不同的jQuery动画。我似乎无法发现价值?
<script>
$(document).ready(function(){
$('.knob').bind('change', function(){
var newvalue = $(this).val();
if (newvalue == 50) {
alert("newvalue is 50!");
};
});
});
</script>
<input class="knob" data-width="530" data-min="0" data-max="67" data-angleOffset="0" data-thickness=".1" data-displayPrevious="true">
我怎么能这样做?希望你能帮忙!
答案 0 :(得分:2)
$(".knob").knob({
change: function (value) {
console.log("changed to: " + value);
}
});
答案 1 :(得分:2)
有点晚了但遇到了同样的问题,我最终得到了这个:
$('.dial').trigger('configure', {
'change': function (v) {
console.log('new value' + v);
}
});
答案 2 :(得分:0)
查看示例here,它将值作为第一个参数传递。
$('.knob').bind('change', function(val){ console.log(val); });
答案 3 :(得分:0)
您可以通过以下方式控制标签的字体大小: -
$(".knob").css('font-size','15px');
you can set the font size of your own choice like 20px,30px,etc.
if you are getting the chart build dynamically then here is the javascript/jquery code for you
********javascript**************
var a = document.getElementsByClassName("knob");
for (var i = 0; i
if (a[i].value > 400) a[i].style.fontSize = "15px";
}
again here you can set the font - size of your choice.
* * * * * * * jquery * * * * * * * * * * * * * * * * * * * * *
var a = $('.knob');
a.each(function () {
if (this.value > 99999) this.style.fontSize = "15px";
if (this.value > 9999 && this.value <= 99999) this.style.fontSize = "17px";
else if (this.value > 999 && this.value <= 9999) this.style.fontSize = "20px";
});
apply as many conditions as you want and change the font size.
答案 4 :(得分:0)
使用此:
$('.dial').knob({
change: function (value) {
this.$.attr('value',Math.round(value))
},
release : function (value) {
this.$.attr('value',Math.round(value))
}
})
现在您可以随时获取$ input.val来获取值。不是吗?