I am using the below code to have an increment and decrement functionality. But somehow it is not fixed to one digit after decimal places it works fine on Firefox but chrome sometimes adds trailing zeros or other random numbers.
How to fix it.
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.qty-inc').click(function () {
jQuery('.qty-default').val(Number(jQuery('.qty-default').val()) 0.1);
});
jQuery('.qty-dec').click(function () {
var value = Number(jQuery('.qty-default').val())-0.1;
if(value > 0){
jQuery('.qty-default').val(value);
}
});
});
</script>
CodePudding user response:
var finalvalue = value.toFixed(1);