简体   繁体   中英

Detecting jQuery knob value

Hi guys I've spent hours trying to solve this small problem, I want to use this jQuery knob to trigger different jQuery animations at each point. I can't seem to detect the value?

<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">

How could I do this? Hope you can help!

$(".knob").knob({
    change: function (value) {
        console.log("changed to: " + value);
    }
});

A little bit late but ran into the same question, I ended up with this:

$('.dial').trigger('configure', {
    'change': function (v) {
        console.log('new value' + v);
    }
});

看一下这里的例子,它将值作为第一个参数传递。

$('.knob').bind('change', function(val){ console.log(val); });

you can control the font-size of the labels by:-

$(".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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM