The below solution works great for a simple live calculation however, I am trying to make one small change. I want to round the answer always to 2 decimal places. I have tried adding .toFixed(2) to various points but it doesn't seem to work. Like this,
<script type="text/javascript">
$(document).ready(function() {
$("#mytextfield").on('keyup',function(){
// alert('pressed')
var totalcost= $("#totaldays").val() * $(this).val()
$(".total_cost").text(totalcost).toFixed(2);
})
});
</script>
Can anyone tell me how I can achieve two decimal places?
Thanks