jQuery – Convert string to int float or double

jQuery doesn’t have a built-in function to carry out this task because JavaScript already had them.

Convert string to int

JavaScript parseInt() function can convert any string with number to int.

=> 10
=> 10

Convert string to float or double

To convert String to float or double in jQuery, use JavaScript parseFloat() function. It parses a string and returns a floating point number.

=> 123.23
parseFloat("1.2 2.3 3.4");
=> 1.2

Leave a Comment

Your email address will not be published. Required fields are marked *

We care about your privacy and data security. Google serves cookies to analyse traffic and show ads on this site. By using this site you agree to these cookies being set. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.