1、插件名字jQuery-Knob-master
下載地址https://github.com/aterrien/jQuery-Knob
2、常用參數說明:
- <script>
- $(function() {
- $(".dial").knob({
- width:100,//寬度
- thickness:0.2,//厚度按百分幾計算
- fgColor:'#f90',//前景色
- //displayInput:false,//不顯示input
- //bgColor:'#000',//背景色
- readOnly:true,//只讀
- //linecap:'round',
- //inputColor:'#f60', //數字的顏色
- });
- });
- </script>
完整案例:
- <!DOCTYPE html>
- <html>
- <head>
- <title>jQuery Knob demo</title>
- <script src="js/jq.js"></script>
- <!--[if IE]><script type="text/javascript" src="excanvas.js"></script><![endif]-->
- <script src="js/jquery1.knob.js"></script>
- <style>
- .box{width:100px;height:100px;position: relative;overflow:hidden;}
- .box canvas{position: absolute;top:0;left:0;width:100px;}
- .box span{line-height:100px;display:inline-block;width:100px;text-align:center;}
- </style>
- </head>
- <body>
- <div class="box">
- <input type="text" value="70" class="dial" >
- <span>70%</span>
- </div>
- <div class="box">
- <input type="text" value="10" class="dial" style="display:none">
- <span>10%</span>
- </div>
- <div class="box">
- <input type="text" value="30" class="dial" style="display:none">
- <span>30%</span>
- </div>
- <script>
- $(function() {
- $(".dial").knob({
- width:100,//寬度
- thickness:0.2,//厚度按百分幾計算
- fgColor:'#f90',//前景色
- //displayInput:false,//不顯示input
- //bgColor:'#000',//背景色
- readOnly:true,//只讀
- //linecap:'round',
- //inputColor:'#f60', //數字的顏色
- });
- });
- </script>
- </body>
- </html>
解決id7/8下進度在100%的情況下沒有前景色
爲了兼容坑爹的垃圾ie可以在100%進度下單獨設置背景色和前景色爲同一顏色,於是自己又改了一下
- $.fn.knob_progress=function(options){
- var defaults={
- width:55
- };
- var opts = $.extend({},defaults,options);
- $(this).each(function(){
- $this=$(this);
- if($this.val()<100){
- $this.knob({
- width:opts.width,
- thickness:0.15,
- fgColor:'#f90',
- displayInput:false,
- readOnly:true
- });
- }else{
- $this.knob({
- width:opts.width,
- thickness:0.15,
- fgColor:'#f90',
- bgColor:'#f90',
- displayInput:false,
- readOnly:true
- });
- }
- });
- };
完整案例下載地址:
360雲盤。。