jQuery get text as number

后端 未结 6 2155
轮回少年
轮回少年 2020-12-24 06:03

This code doesn\'t work:

var number = $(this).find(\'.number\').text();
var current = 600;
if (current > number){
     // do something
}
         


        
6条回答
  •  自闭症患者
    2020-12-24 06:43

    If anyone came here trying to do this with a decimal like me:

    myFloat = parseFloat(myString);

    If you just need an Int, that's well covered in the other answers.

提交回复
热议问题