A text input’s value
attribute will always return a string. You need to parseInt
the value to get an integer:
parseInt($('#myInput').val(), 10);
More Related Contents:
- Escaping HTML strings with jQuery
- Evaluating a string as a mathematical expression in JavaScript
- Why does JavaScript handle the plus and minus operators between strings and numbers differently?
- What’s the best way to convert a number to a string in JavaScript?
- Format numbers in JavaScript similar to C#
- Javascript Thousand Separator / string format [duplicate]
- Check whether an input string contains a number in javascript
- How to find if an array contains a specific string in JavaScript/jQuery?
- Add st, nd, rd and th (ordinal) suffix to a number
- Format a number as 2.5K if a thousand or more, otherwise 900
- Remove whitespace and line breaks between HTML elements using jQuery
- add commas to a number in jQuery
- JavaScript string and number conversion
- Wrap tags around http text
- Convert javascript array to string
- Split a string based on multiple delimiters
- How to trim() white spaces from a string?
- Insert space before capital letters
- jQuery call function from a string [duplicate]
- How Can I Truncate A String In jQuery?
- JavaScript adding a string to a number
- Javascript: How to retrieve the number of decimals of a *string* number?
- Remove/ truncate leading zeros by javascript/jquery
- Javascript / Jquery – Get number from string
- How to test if a URL string is absolute or relative?
- Put quotes around a variable string in JavaScript
- Regex in JavaScript for validating decimal numbers
- How to check if a string is a legal “dd/mm/yyyy” date?
- How to get text between two characters?
- Find and replace nth occurrence of [bracketed] expression in string