JQuery Knob display number change

后端 未结 3 856
终归单人心
终归单人心 2020-12-30 15:23

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

3条回答
  •  北海茫月
    2020-12-30 15:38

    I managed to achieve this with animation too:

    My solutions does this by adding the percentage each time the value gets increased:

    $(function() {
          $('.dial_overall').each(function () {
    
               var $this = $(this);
               var myVal = $this.attr("value");
    
               $this.knob({
               });
    
               $({
                   value: 0 
               }).animate({
    
                   value: myVal
               }, {
                   duration: 1600,
                   easing: 'swing',
                   step: function () {
                       $this.val(Math.ceil(this.value)).trigger('change');
                         $('.dial_overall').val($('.dial_overall').val() + '%');
                   }
    
               })   
           });
    
        });
    

提交回复
热议问题