I have a list <li>Baths 2.00</li> and i want to remove .00 to show only the decimal 2
How i can remove the decimal part with jQuery.
Do you have any solutions?
Regards
On
Here is some example mate..Hope this might help u ...:)
IF you have the part that contains the number in a variable or something use the below
var iNum = 5.123456;
The toPrecision() method formats a number to a specified length.
iNum.toPrecision(); // Returns 5.123456
iNum.toPrecision(5); // Returns 5.1235
iNum.toPrecision(1); // Returns 5
The toFixed() method converts a number into a string, keeping a specified number of decimals.
iNum.toFixed(2); // Returns "5.12"
//Removes the part after the point.Be sure there is not point part that comes in the word part..:)
var value = $('li').text();
$('li').text(value.split('.')[0])
you should use
toFixed:123.45.toFixed(0)//123And it's not related to jQuery but pure JS.
regarding your html : (assuming the numbers are at last place)
http://jsbin.com/ifoZOjE/3/edit