I have a common <input type="text" id="foo" />
I can select all text on click by $("#foo").select();
The field does already contain a number (e.g. 25.40)
How can I select only the 25 part?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For cross-browser support, you could use my Rangy Inputs jQuery plug-in for this, which will also work on textareas: http://code.google.com/p/rangyinputs/
With it, you can select everything before the decimal point as follows:
jsFiddle example: http://jsfiddle.net/3XkJE/2/