我有一个进度条(jquery,CSS),根据下拉列表中的选项,按下过滤器按钮,它为进度条指定一个值,然后开始填充栏,最小值为0,最大值为342 ,计数器工作,问题是进度条,例如,如果你给它20,它开始根据20值填充栏,但如果你将数字更改为50(例如),计数器从0到50开始但是填充条从最后一个给定点(20)开始填充条形图,我应该如何从0点开始使这个条形填充进度条?
这是代码:
$("#btnFilter").click(function () {$.ajax({
dataType: "json",
type: "POST",
url: "@Url.Action("fault_crew","Dashbrd")",
contentType: "application/json; charset=utf-8",
data: JSON.stringify({ "regionalManager": dtDrpVals.drpValue}),
success: function (result) {
var numberOfStudents = null;
numberOfStudents= result[0].Number_Of_Students;
//Circular chart to show number of Students
$.fn.progresscir = function (options) {
var circleMultiplier = (360 / options.total) || 3.6,
progresscir = $(this),
completed = options.completed;
if (completed > options.total / 2) {
progresscir.addClass('gt50');
}
var text = '<strong>' + completed + '</strong>';
progresscir.find('.result-text').html(text);
var rotationDegrees = circleMultiplier * completed;
$('.bar', progresscir).css({
'-webkit-transform': 'rotate(' + rotationDegrees + 'deg)',
'-moz-transform': 'rotate(' + rotationDegrees + 'deg)',
'-ms-transform': 'rotate(' + rotationDegrees + 'deg)',
'-o-transform': 'rotate(' + rotationDegrees + 'deg)',
'transform': 'rotate(' + rotationDegrees + 'deg)'
});
};
// end of jQuery wdget.
// call the widget
function showProgress(completed, total) {
$('#custom1').progresscir({
completed: completed,
total: total});}
var start = 0,
end = numberOfTurbines,
total = 342,
t;
t = setInterval(function () {
showProgress(start, total);
start++;
if (start - 1 === end) {
clearInterval(t);
$('.progresscir').css('background-color', 'white');
}
}, 0);
我是java脚本中的新手,但我觉得它与DOM有关,我每次在重新初始化之前应该如何从DOM中清除它?