<html>
<head >
<title>无标题页</title>
<style type="text/css">
#btnReg {
width: 63px;
}
</style>
<script type ="text/javascript" >
function $(id){
return document .getElementById (id);
}
var remain=10;
function init(){
$("btnReg").innerHTML="注册("+(remain --)+")秒";
if(remain >0)
{
setTimeout (init,1000);
}
else{
$("btnReg").disabled=false ;
$("btnReg").innerHTML="注册";
}
}
</script>
</head>
<body onload ="init()">
<div>
<input id="btnReg" type="button " disabled="disabled" />
</div>
</body>
</html>
<head >
<title>无标题页</title>
<style type="text/css">
#btnReg {
width: 63px;
}
</style>
<script type ="text/javascript" >
function $(id){
return document .getElementById (id);
}
var remain=10;
function init(){
$("btnReg").innerHTML="注册("+(remain --)+")秒";
if(remain >0)
{
setTimeout (init,1000);
}
else{
$("btnReg").disabled=false ;
$("btnReg").innerHTML="注册";
}
}
</script>
</head>
<body onload ="init()">
<div>
<input id="btnReg" type="button " disabled="disabled" />
</div>
</body>
</html>
function init(){
$("btnReg").innerHTML="注册("+(remain --)+")秒";
}
改写成: function init(){
$("btnReg").innerText="注册("+(remain --)+")秒";
}
<head >
<title>无标题页</title>
<meta HTTP-EQUIV ="Content-Type" content="text/html;charset=utf-8">
<style type="text/css">
#btnReg {
width: 63px;
}
</style>
<script type ="text/javascript" >
function $(id){
return document.getElementById(id);
}
var remain=10; function init(){
$("btnReg").value="注册("+(remain --)+")秒";
if(remain >0)
{
setTimeout (init,1000);
}
else{
$("btnReg").disabled=false ;
$("btnReg").value="注册";
}
}
</script>
</head>
<body onload ="init()">
<div>
<input id="btnReg" type="button" disabled="disabled" />
</div>
</body>
</html>