一个简单的js计数器(web储存)。

 1 <span id="countspan"></span>
 2 <a href="#" onclick="countNumber();">点击</a>
 3 <script type="text/javascript">
 4 if(!localStorage.countAll){           
 5     localStorage.countAll = 0;
 6 }
 7 document.getElementById('countspan').innerHTML = localStorage.countAll;
 8 function countNumber(){
 9     localStorage.countAll++;
10     document.getElementById('countspan').innerHTML = localStorage.countAll;
11 }
12 </script>

 

posted @ 2016-04-28 11:34  wong。  阅读(528)  评论(0编辑  收藏  举报