Possible Duplicate:
Is JavaScript’s Floating-Point Math Broken?
Rounding a float in JavaScript
Why this function increase wrong decimal values? I want to show only one decimal.
var valueElement = $('#valueTempe');
function incrementValue(e){
if(valueElement.text() < 6){
valueElement.text(Math.max(parseFloat(valueElement.text()) + e.data.increment));
}
return false;
}
$('#plus').bind('click', {increment: 0.1}, incrementValue);
$('#minus').bind('click', {increment: -0.1}, incrementValue);
jsFiddle: Test
You can use .toFixed(1) as below
Demo