如何使用jquery累积或删除小数
HTML:
<button>Run</button>
<p>
<span class='aaa'>333</span>
<span class='bbb'></span>
</p>
jQuery:
// jquery
$(document).ready(function(){
$("button").click(function(){
var aaa = $(".aaa").html();
var bbb = aaa * 12/100;
$(".bbb").html(bbb);
});
});
提前谢谢
$(document).ready(function(){
$("button").click(function(){
var aaa = $(".aaa").html();
var bbb = aaa * 12/100;
$(".bbb").html(bbb);
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>Run</button>
<p>
<span class='aaa'>333</span>
<span class='bbb'></span>
</p>
&#13;
答案 0 :(得分:1)
console.log(Math.round(39.96));
console.log(Math.round(39.40));
// jquery
$(document).ready(function(){
$("button").click(function(){
var aaa = $(".aaa").html();
var bbb = Math.round(aaa * 12/100);
$(".bbb").html(bbb);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>Run</button>
<p>
<span class='aaa'>333</span>
<span class='bbb'></span>
</p>