var test = parseInt($("#testid").val(), 10);

You have to tell it you want the value of the input you are targeting.

And also, always provide the second argument (radix) to parseInt. It tries to be too clever and autodetect it if not provided and can lead to unexpected results.

Providing 10 assumes you are wanting a base 10 number.

Answer from jondavidjohn on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › parseInt
parseInt() - JavaScript | MDN
The parseInt function converts its first argument to a string, parses that string, then returns an integer or NaN.
🌐
W3Schools
w3schools.com › JSREF › jsref_parseint.asp
W3Schools.com
The parseInt method parses a value as a string and returns the first integer.
🌐
Telerik
telerik.com › javascript › kendo › parseint
parseInt - API Reference - Kendo UI kendo - Kendo UI for jQuery
parseInt · Parses as a string as an integer. Example · View Source · Edit in Kendo UI Dojo · Edit · <script src="https://kendo.cdn.telerik.com/2026.2.520/js/cultures/kendo.culture.de-DE.min.js"></script> <script> /* The result can be observed in the DevTools(F12) console of the browser.
🌐
Edureka Community
edureka.co › home › community › categories › web development › jquery › parseint with jquery
parseInt with jQuery | Edureka Community
June 9, 2022 - Can someone help me figuring out why the following jQuery code doesn't work? I want to return a integer ... parseInt($("#testid")); Thank you & bye!
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-number-parseint-method
JavaScript Number parseInt() Method - GeeksforGeeks
February 6, 2026 - The parseInt() method parses a value by converting it to a string and returns the first integer found.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › parseInt
Number.parseInt() - JavaScript | MDN
The Number.parseInt() static method parses a string argument and returns an integer of the specified radix or base.
Find elsewhere
🌐
Tabnine
tabnine.com › home › how to use parseint() in javascript
How to Use parseInt() in JavaScript - Tabnine
July 25, 2024 - In the above code, despite the strings containing two different values, the same result is returned in both cases. This happens because parseInt(y, 16) stopped reading the string when it encountered the ‘G’ character, as the character ‘G’ is not a valid character in the hexadecimal number system.
🌐
Priyanku's Blog
priyankuhazarika.hashnode.dev › weird-javascript-the-strange-behaviour-of-parseint
Weird Javascript: The Strange behaviour of parseInt()
July 18, 2023 - When we call parseInt() on a small decimal number like 0.0000003, it first converts the number to a string representation and then it simply takes the first character from that string !!
🌐
DEV Community
dev.to › darkmavis1980 › you-should-stop-using-parseint-nbf
You should stop using `parseInt()` - DEV Community
October 15, 2021 - Ok, but you did sum up the issue yourself in the examples. ParseInt will order to an integer whereas Number will get the proper numeric representation. Which means the outcome ma not be an int, which is what ParseInt guarantees .
🌐
Dustin John Pfister
dustinpfister.github.io › 2019 › 05 › 15 › js-parseint
parseInt and other options for parsing numbers in javaScript | Dustin John Pfister at github pages
September 9, 2021 - The parseInt function is one of several ways to convert a string to a number in javaScript. The parseInt method does convert a string or number to an integer, but technically it is still a float as al
🌐
Scaler
scaler.com › home › topics › parseint() in javascript
ParseInt() in JavaScript - Scaler Topics
January 1, 2024 - The JavaScript parseInt() function is a built-in function that is used to parse a string argument to return the first integer. The number system to use is specified by a radix parameter.
🌐
Server2client
server2client.com › javascriptref › parseint.html
JavaScript Reference - Global function - parseInt()
jQuery · Quick Reference · Case Studies · Quizzes · Global function that converts a string to an integer. Parses a string argument with an optional radix and attempts to return an integer. Below are some examples of using the parseInt() function. // Parsing string to integers.
🌐
DEV Community
dev.to › judevector › understanding-parseint-in-javascript-usage-quirks-and-best-practices-1dl7
Understanding parseInt in JavaScript: Usage, Quirks, and Best Practices - DEV Community
October 5, 2023 - Passing an invalid string or a string with mixed characters to parseInt can yield unexpected results. If the string starts with a numeral, parseInt will continue parsing until it reaches a non-numeric character and then return the integer value parsed so far.
🌐
Obfuscator
obfuscator.io
JavaScript obfuscator tool - Protect Your JS Code
Powerful JavaScript obfuscation tool to protect your source code
🌐
Career Karma
careerkarma.com › blog › javascript › javascript parseint: a step-by-step guide
JavaScript ParseInt: A Step-By-Step Guide | Career Karma
December 1, 2023 - We assign a value to a JavaScript variable called “value”. Our value is a string, which is indicated by the quotation marks surrounding the value. Then, we use the parseInt() method to convert that value to an integer.
🌐
jQuery
api.jquery.com › Types
Types | jQuery API Documentation
parseInt and parseFloat help parsing strings into numbers.
🌐
Team Treehouse
teamtreehouse.com › community › how-to-parseint-the-value-of-a-text-input-field
How to parseint the value of a text input field? (Example) | Treehouse Community
June 28, 2017 - I tried this: $( "input#studentQuant" ).change(function() { $("parseInt($('input#studentQuant);").prop('max',10); });
🌐
Educative
educative.io › answers › how-to-use-the-parseint-function-in-javascript
How to use the parseInt() function in JavaScript
The parseInt() function is a built-in function in JavaScript which allows users to convert a string to an integer value.