How to display units with Jquery Knob

╄→гoц情女王★ 提交于 2019-12-02 11:53:22

问题


I'm using Jquery knob (http://anthonyterrien.com/knob/) and it works great but rather than have a dimentionless number displayed in the middle I would like to display units with it ei % or F etc ... How can I do this?


回答1:


$("input.Measure").knob({
        min: 1
        max: 10
        stopper: true,
        readOnly: false,//if true This will Set the Knob readonly cannot click
        draw: function () {
             $(this.i).val(this.cv + '%') //Puts a percent after values
        },
        release: function (value) {
      //Do something as you release the mouse
    }
});



回答2:


As Ben explains on Adding Percentages to jquery knob input value, on the recent versions (>1.2.7) you can use the format hook:

$(".dial").knob({
  'format' : function (value) {
     return value + '%';
  }
});


来源:https://stackoverflow.com/questions/18955708/how-to-display-units-with-jquery-knob

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!