简体   繁体   English

使用jQuery显示进度条百分比

[英]Display progress bar percentage using jquery

I am trying to display percentage of progress .So, I've given a span with class percentage to display it there and id of progress bar is "progressbar". 我正在尝试显示进度百分比。因此,我给了一个带有类百分比的跨度以在那里显示进度栏,进度栏的ID为“ progressbar”。 My js code is, 我的js代码是

$("#progressbar").progressbar({
  value: 50
});

$(document).ready(function() {

  $("#progressbar").progressbar({
    value: 0
  });
  var progress = setInterval(function() {
    var currentVal = $("#progressbar").progressbar("value");
    var nextVal = currentVal + 1;
    $('#percentage').text(currentVal);
    if (nextVal > 90) {
      clearInterval(progress);
    } else {
      $("#progressbar").progressbar({
        value: nextVal
      });
    }

  }, 100);
});

Now how can I display percentage at #percentage 现在如何显示#percentage百分比

Thanks in Advance. 提前致谢。

Isn't 是不是

var currentVal = $("#progressbar").progressbar("option", "value");

supposed to be 应该是

var currentVal = $("#progressbar").progressbar("value");

These should be your checkpoints 这些应该是您的检查站

  • Include jQuery. 包括jQuery。
  • Include jQuery-ui after jQuery script. 在jQuery脚本之后包含jQuery-ui。
  • Include the css 包括CSS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM