87,990
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html>
<head>
<title></title>
<style type="text/css">
#div { padding:5px; width:220px; height:60px; border:1px solid #daa; font-size:14px; }
</style>
</head>
<body>
<input type="text" id="test" />
<script>
function $(o){return document.getElementById(o)}
function showTime(){
var date = new Date();
date = date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
$('test').value = date;
}
var count = 1, div;
showTime();
setInterval(showTime,1000);
$('test').onfocus = function(){
var date = new Date();
date = date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
div = document.createElement('div');
div.innerHTML = '第 <span style="color:red">' + count + '</span> 次 ' + date;
div.id = 'div';
document.body.appendChild(div);
count++;
}
$('test').onblur = function(){
document.body.removeChild($('div'))
}
</script>
</body>
</html>