<!doctype html>
<html>
<head>
<meta charSet="utf-8">
</head>
<body>
还有<span id="sp">10</span>秒就关机
<script type="text/javascript">
function countdownTime_mannual(){
var spannode=document.getElementbyId("sp");
var num=spannode.innerHTML;
spannode.innerHTML=--num;
}
function countdowntime_auto(){
setInterval(countdownTime_mannual(){},1000)
}
/**
问题:为什么我执行过后,手动倒计时和自动倒计时都需要点击按钮才减少一秒,自动倒计时完成不了,求解
*/
</script>
<input type="button" value="手动倒计时" onclick="countdownTime_mannual()"/>
<input type=""button" value="自动倒计时" onclick="countdowntime_auto()"/>
</body>
</html>
setInterval(countdownTime_mannual(){},1000);
换成
setInterval(countdownTime_mannual,1000);
非常感谢
/**
* 1.第二个button多了个"
* 2.getElementById
* 3.如楼上所说
* */