<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>
.red{background:red;}
</style>
<script>
window.onload=function()
{
var aButton=document.getElementsByTagName('input');
var oDiv=document.getElementById('timer');
var timer=null;
var times=0;
for(var i=0;i<aButton.length;i++)
{
aButton[i].onclick=function()
{
clearInterval(timer);
if(this.className=='')
{
this.className='red';
for(var i=0;i<aButton.length;i++)
{
if(aButton[i]!=this)
{
aButton[i].className='';
aButton[i].disabled=true;
}
}
}
else
{
this.className='';
for(var i=0;i<aButton.length;i++)
{
if(aButton[i]!=this)
{
aButton[i].className='';
aButton[i].disabled=false;
}
}
times=0;
timer=setInterval(function(){
oDiv.innerHTML=times++;
},1000);

}


}
}
}</script>
</head>
 
<body>
    <input type="button" value="按钮一" />
    <input type="button" value="按钮二" />
    <input type="button" value="按钮三" />
    <input type="button" value="按钮四" />
    <input type="button" value="按钮五" />
    <div class="timer" id="timer">
     开始计时
    </div>
</body>
</html>