JQuery Knob显示数字更改 [英] JQuery Knob display number change

查看:463
本文介绍了JQuery Knob显示数字更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 JQuery Knob 制作一些很酷的图表,并且它运行良好。但我有一个问题:我想让图表之间的显示数字连接起来'%'。但我似乎无法使它成功。通过jquery修改输入不会这样做,我已经尝试读入库的代码,但没有运气。还有其他人之前遇到过这个问题吗?

I'm using JQuery Knob to make some cool graphs and it's working perfectly. But I have one problem: I want to make the display number between the graph have a '%' symbol concatenated. but I just cant seem to make it work. Modifying the input through jquery wont do it, and I've tried reading into the code of the library but with no luck. Has any one else had this problem before?

推荐答案

如果你快速浏览一下github repo,你会看到有每次绘制画布时调用的绘制钩子。如果你实现了这个钩子,你应该能够在输入中添加你想要的任何东西。以下是您正在寻找的功能的简短示例(尝试它: http://jsfiddle.net/eAQA2/ )和供将来参考:

If you take a quick look at the github repo you'll see that there's a draw hook that's called everytime the canvas is drawn. If you implement that hook you should be able to add whatever you wish to the input. Here's a short example of the functionality you're looking for (to try it: http://jsfiddle.net/eAQA2/ ) and for future reference:

<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="https://raw.github.com/aterrien/jQuery-Knob/master/js/jquery.knob.js"></script>
<script>
$(function() {
    $(".dial").knob({
      'draw' : function () { 
        $(this.i).val(this.cv + '%')
      }
    })
})
</script>
</head>
<body>
<input type="text" class="dial" data-min="0" data-max="100">
</body>
</html>​

这篇关于JQuery Knob显示数字更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆