2

大家好,我花了几个小时试图解决这个小问题,我想使用这个jQuery 旋钮在每个点触发不同的 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">

我怎么能这样做?希望你能帮忙!

4

5 回答 5

3
$(".knob").knob({
    change: function (value) {
        console.log("changed to: " + value);
    }
});
于 2012-07-06T17:06:15.860 回答
1

有点晚了,但遇到了同样的问题,我最终得到了这个:

$('.dial').trigger('configure', {
    'change': function (v) {
        console.log('new value' + v);
    }
});
于 2012-12-23T21:44:38.633 回答
0

查看此处的示例,它将值作为第一个参数传递。

$('.knob').bind('change', function(val){ console.log(val); });
于 2012-07-06T17:06:58.187 回答
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.
于 2013-07-26T14:03:22.117 回答
0

用这个:

         $('.dial').knob({
                change: function (value) {
                    this.$.attr('value',Math.round(value))
                },
                release : function (value) {
                    this.$.attr('value',Math.round(value))
                }
            })

现在您可以随时获取 $input.val 来获取值。Smart 不是吗?

于 2019-09-26T20:42:17.717 回答