18910140161

JavaScript-使用jQuery和HTML时进度条不工作-堆栈溢出

顺晟科技

2022-10-18 14:00:47

122

我已经在我的多步骤表单上实现了一个进度条。但在提交表单后,进度条不会显示为页面重新加载。在下面找到我的代码。

$(document).ready(function() {
    $('#myBtn').click(function(){
        animateProgressBar(90);
 //mybtn is the button id of submit button in form   
    
    
    });
function animateProgressBar(percentageCompleted)
{

$('#innerDiv').animate({
   
'width':(1000*percentageCompleted)/100 


},1000);
$({counter: 1}).animate({counter:percentageCompleted},{duration:1000,
step:function()
{
    $('#innerDiv').text(Math.ceil(this.counter)+'%');
}

})
}

});
<代码><;DIV ID=“ outerdiv ” style=" background-color:白色;高度:20px;宽度:1000px;填充:5px;>;<;DIV ID=“ innerdiv ” style=" background-color:#138581;高度:19px;宽度:0px;颜色:白色;文本对齐:居中;>;<;/DIV>;<;/DIV>;


顺晟科技:

您可以使用localStorage来保持页面重新加载之间的进度。

使用 <div id="outerDiv" style="background-color:white; height:20px; width:1000px; padding:5px;"> <div id="innerDiv" style="background-color:#138581; height:19px; width:0px; color:white; text-align:center;"> </div></div>在窗体中设置当前步骤的进度。

使用window.localStorage.setItem('progress', 90);来检索您之前设置的进度。

因此,您可以在localStorage中设置当前进度,并在每次刷新时检索它并再次显示它。

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航