Home  >  Article  >  Web Front-end  >  Use parseInt for data type conversion during js numerical calculation (jquery)_javascript skills

Use parseInt for data type conversion during js numerical calculation (jquery)_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:34:441589browse

The data obtained by js is of string type by default. If you perform numerical operations, you must use parseInt to convert into numerical values.

html code:

Copy code The code is as follows:




js code:

Copy code The code is as follows:

$("#archive").bind('click',function(){
                         
var page=$("input[name='page']").val();
//Use parseInt to perform numerical operations
$("input[name='page']").val(parseInt(page) 1);

});

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn