How can I change an HTML input value's data type to integer?

后端 未结 5 1945
耶瑟儿~
耶瑟儿~ 2021-01-12 00:39

I\'m using jQuery to retrieve a value submitted by an input button. The value is supposed to be an integer. I want to increment it by one and display it.

//          


        
5条回答
  •  难免孤独
    2021-01-12 01:36

    Use parseInt as in: var count = parseInt($("#"+countUp).val(), 10) + 1; or the + operator as in var count = +$("#"+countUp).val() + 1;

提交回复
热议问题