好多人都沒寫投票總數(shù)?
<!DOCTYPE html>
<html>
<head>
? ? <meta charset="UTF-8">
? ? <title></title>
? ? <style type="text/css">
? ? ? ? .con {
? ? ? ? ? ? width: 200px;
? ? ? ? ? ? height: 200px;
? ? ? ? ? ? background: red;
? ? ? ? }
? ? ? ? .tou {
? ? ? ? ? ? width: 200px;
? ? ? ? ? ? height: 30px;
? ? ? ? ? ? line-height: 30px;
? ? ? ? ? ? background: #a7cbff;
? ? ? ? }
? ? ? ? .tou button {
? ? ? ? ? ? float: left;
? ? ? ? }
? ? ? ? .tou .ret {
? ? ? ? ? ? float: right;
? ? ? ? }
? ? </style>
? ? <script type="text/javascript">
? ? ? ? function vote(e){
? ? ? ? ? ? var a=document.getElementById('total');? ??
? ? ? ? ? ? var num=parseInt(a.innerHTML)+1;
? ? ? ? ? ? a.innerHTML=num;
? ? ? ? ? ? ? disable(e);
? ? ? ? }
? ? function disable(e){
? ? ? ? e.disabled=true;
? ? ? ? setTimeout(function(){
? ? ? ? e.disabled=false;
? ? ? ? ? ? },5000);
? ? }
? ? </script>
</head>
<body>
<div class="con">投票內(nèi)容</div>
<div class="tou">
? ? <button onclick="vote(this)">投票</button>
? ? <span class="ret">總票數(shù):<span id="total">0</span></span>
</div>
</body>
</html>
2019-01-20
嗯,你這樣寫也是對(duì)的,不過我試了一下,其實(shí)函數(shù)傳不傳參沒什么關(guān)系,不影響效果,加油