【发布时间】:2020-03-05 15:34:09
【问题描述】:
如何只显示一个计数器的十进制值?目前它的四舍五入到 4.7 到 5
$('.count').each(function() {
$(this).prop('Counter', 0).animate({
Counter: jQuery(this).text()
}, {
duration: 4000,
easing: 'swing',
step: function(now) {
$(this).text(Math.ceil(now));
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="shiva"><span class="count">200</span></div>
<div id="shiva"><span class="count" id="reducedaily">4.7</span></div>
【问题讨论】:
-
试试这个:(4.7 % 1).toFixed(1)。 stackoverflow.com/questions/4512306/… 这个问题应该以重复的形式关闭。
标签: javascript jquery counter