jQuery get text as number

Always use parseInt with a radix (base) as the second parameter, or you will get unexpected results: var number = parseInt($(this).find(‘.number’).text(), 10); A popular variation however is to use + as a unitary operator. This will always convert with base 10 and never throw an error, just return zero NaN which can be tested with …

Read more