This will alert 23.
alert(parseInt(\'23 asdf\'));
But this will not alert 23 but alerts NaN
alert(parseInt(\'asdf 23\'));
You have to use regular expression to extract the number.
var mixedTextAndNumber= 'some56number'; var justTheNumber = parseInt(mixedTextAndNumber.match(/\d+/g));