求简单的js点击计数代码

JavaScript013

求简单的js点击计数代码,第1张

计数:<span id="countspan"></span>

<a href="#" onclick="countNumber()">点击</a>

<script type="text/javascript">

if(!localStorage.countAll){

localStorage.countAll = 0

}

document.getElementById('countspan').innerHTML = localStorage.countAll

function countNumber(){

localStorage.countAll++

document.getElementById('countspan').innerHTML = localStorage.countAll

}

</script>

支持html5的浏览器都能用。

document写错了,。

window.onload=function(){

var oRecord=document.getElementById("record")

var oTime=document.getElementById("time")

var result=0

oTime.onclick=function(){

result+=1

oRecord.innerHTML=result

}

}

result不要加“”号