admin管理员组文章数量:1393037
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!
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!
Share Improve this question edited Jul 6, 2012 at 17:01 epascarello 208k20 gold badges205 silver badges244 bronze badges asked Jul 6, 2012 at 16:56 JoeJoe 4573 gold badges8 silver badges26 bronze badges 3-
You need to fetch the value of the
input
tag. Look at the DOM to see how it's set up. – TheZ Commented Jul 6, 2012 at 17:00 - I am trying to do that in the code above? – Joe Commented Jul 6, 2012 at 17:04
-
try giving your input a
type
attribute? – DA. Commented Jul 6, 2012 at 17:05
5 Answers
Reset to default 3$(".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);
}
});
Looking at the example here, it passes the value as the first argument.
$('.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.
use this:
$('.dial').knob({
change: function (value) {
this.$.attr('value',Math.round(value))
},
release : function (value) {
this.$.attr('value',Math.round(value))
}
})
now you can just get $input.val to get the value whenever you want.Smart ain't it?
本文标签: javascriptDetecting jQuery knob valueStack Overflow
版权声明:本文标题:javascript - Detecting jQuery knob value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744734201a2622225.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论