我正在尝试创建一个倒数进度条(就像进度条从100%变为0%的相反)。
我有from collections import Counter
s = ['abcabcbb', ' ', 'abba', 'uqinntq']
for ss in s:
#If string is non-empty
if ss.strip():
#This will help us calculate frequencies of all characters
c = Counter(ss)
print(ss)
for key, value in c.items():
#If characters are repeated, print them
if value > 1:
print('{} is repeated {} times'.format(key, value))
,其宽度为100%,并希望在几秒钟的时间内缩小到0-然后页面将重新加载。
我希望在jQuery中做到这一点。
答案 0 :(得分:1)
您可以像这样实现div的间隔并设置宽度
var progressBar = $('#progress-bar'),
width = 100;
var interval = setInterval(function() {
width -= 1;
progressBar.css('width', width + '%');
if (width == 0) {
clearInterval(interval);
//redirect page here
//window.unload(function(){});
}
}, 1000)
var progressBar = $('#progress-bar'),
width = 100;
var interval = setInterval(function() {
width -= 1;
progressBar.css('width', width + '%');
if (width == 0) {
clearInterval(interval);
//redirect page here
//window.unload(function(){});
}
}, 1000)
#progress-bar {
height: 10px;
background: green;
text-align: center;
overflow: hidden;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="progress-bar"></div>