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

JavaScript保存并运算页面中数字类型变量的写法_javascript技巧

WBOY
Release: 2016-05-16 15:51:19
Original
1012 people have browsed it

之前在html页面嵌入一段如下javascript片段,但是在单击一个按钮的时候会对i值加一,但是两次单击之后,i的初始值没变。

复制代码 代码如下:



后来把变量声明在一个test对象里面,如下代码。这样每次变更test.i之后,test.i的值就可以保存下来

复制代码 代码如下:


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!