Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 16:34:44
Original
1588 people have browsed it

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);

});

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!