jQuery get text as number
by Francis[ Edit ] 2013-01-21 13:05:19
jQuery get text as number
Use unitary operator to convert text as a number, and validate the text have string or numbers,
In Html,
<div class="number">400</div>
In Jquery,
var num = +($('div.number').text()); // unitary operator (+)
if(isNaN(num)) // Div text is a number or not to validate
{
alert("The div text is not a number");
}
else
{
alert("The div text is a number");
}