利用HTML5云存储实现模拟对比投票效果

时间:2023-01-07 13:54:44
<!DOCTYPE HTML>
<html>
<head>
<title>模拟对比投票效果</title>
<meta name="description" content="HTML5Web存储" />
</head>
<body>
<span>能(<a href="javascript:;" id="btn">98</a>%)</span>
<span>不能(<a href="javascript:;" id="btn1">2</a>%)</span>
<script type="text/javascript">
var oB=document.getElementById("btn");
var oB1=document.getElementById("btn1");
oB.onclick=function(){
if (localStorage.pagecount<99){localStorage.pagecount=Number(localStorage.pagecount)+3;}
else{localStorage.pagecount=85;}
};
oB1.onclick=function(){
if(Number(oB1.innerHTML)<25){
oB1.innerHTML=Number(oB1.innerHTML)+1;
oB.innerHTML=100-Number(oB1.innerHTML);
}else{}
};
oB.innerHTML=Number(localStorage.pagecount);
oB1.innerHTML=100-Number(localStorage.pagecount);
</script>
</body>
</html>