Reputation: 231
How to accumulated or remove decimal with 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);
});
});
Thank you in advance
$(document).ready(function(){
$("button").click(function(){
var aaa = $(".aaa").html();
var bbb = 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>
Upvotes: 1
Views: 106
Reputation:
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>
Upvotes: 1