日期:2014-05-16 浏览次数:20572 次
<!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>
<script type="text/javascript">
var timer = 0, t;
function timing(buttonID) {
var now = new Date();
now = Math.round(parseInt(now.getTime() / 1000));
document.getElementById(buttonID).value = now - timer;
}
window.onload = function() {
var obj = document.getElementById('demo').getElementsByTagName('input');
for (var i = 0; i < obj.length; i ++) {
obj[i].ondblclick = function() {
for (var j = 0; j < obj.length; j ++) obj[j].disabled = true;
this.disabled = false;
if (this.value == this.id) {
timer = new Date();
timer = Math.round(parseInt(timer.getTime()) / 1000);
t = window.setInterval('timing("' + this.id + '")', 1000);
}
else {
window.clearInterval(t);
for (var j = 0; j < obj.length; j ++) obj[j].disabled = false;
this.value = this.id;
}
}
}
}
</script>
</head>
<body>
<form id="demo">
<input type="button" id="BUTTON1" value="BUTTON1" />
<input type="button" id="BUTTON2" value="BUTTON2" />
<input type="button" id="BUTTON3" value="BUTTON3" />
<input type="button" id="BUTTON4" value="BUTTON4" />
<input type="button" id="BUTTON5" value="BUTTON5" />
<input type="button" id="BUTTON6" value="BUTTON6" />
</form>
</body>
</html>