<script type="text/javascript">
$(document).ready(function() {
$('#btn-add').click(function(){
$('#select-from option:selected').each( function() {
$('#select-to').append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>");
$("input[name='class']").val(parseFloat($(this).val()) + parseFloat($("input[name='class']").val()));
});
});
$('#btn-remove').click(function(){
$('#select-to option:selected').each( function() {
$('#select-from').append("<option value='"+$(this).val()+"'>"+$(this).text()+"</option>");
$(this).remove();
$("input[name='class']").val(parseInt($("input[name='class']").val() - parseInt($(this).val())));
total= $("input[name='class']").val(parseInt($("input[name='class']").val() - parseInt($(this).val())));
});
});
});
</script>
I would like to shorten the number after decimal numbers to 2. Does somebody has any idea
2
Answers
You can use the
toFixed
method.Your code should be:
Example output: 2.01
I prefer this format to use different countries. Try it and tell me.