Friday, January 2, 2015

jquery NaN error

I have just written a small script today with jquery and come across this small error message.
inital code:

var1 += parseInt($(this).html());
var2 = parseFloat(age);

Solution

    var1 += parseInt( $(this).text(), 10 ) || 0;
  var2 = parseFloat(age) || 0;
 
Hope it helps. 

No comments:

Post a Comment