【发布时间】:2018-07-06 18:08:11
【问题描述】:
我在表单上使用了进度条。 我不想添加没有小数的百分比。 当条形高于条形 33.33% 时,应该有一个“33%”。
当我四处搜索时,我只能找到动画加载条的百分比,而不是点击。
这是我的进度条 2 个例子。
(function($){
// First bar
$('.nav.one .next').click(function(){
// Animate progressbar
$(".progressbar.one").animate({
width: "+=33.33%"
},"slow");
});
$('.nav.one .prev').click(function(){
// Animate progressbar
$(".progressbar.one").animate({
width: "-=33.33%"
},"slow");
});
// Second bar
$('.nav.two .next').click(function(){
// Animate progressbar
$(".progressbar.two").animate({
width: "+=25%"
},"slow");
});
$('.nav.two .prev').click(function(){
// Animate progressbar
$(".progressbar.two").animate({
width: "-=25%"
},"slow");
});
})(jQuery);
.progressbar {
height: 20px;
background: lightblue;
display: inline-block;
}
.progressbar.one {
width: 33.33%;
}
.progressbar.two {
width: 25%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>I wan't to show progress bar percent here</p>
<div class="progressbar one"></div>
<div class="nav one"><button class="prev">Prev</button> | <button class="next">Next</button></div>
<hr />
<p>I wan't to show progress bar percent here</p>
<div class="progressbar two"></div>
<div class="nav two"><button class="prev">Prev</button> | <button class="next">Next</button></div>
【问题讨论】:
标签: jquery