楼主的作业啊? 。试试<!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>
交卷! 是这样呗? <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>无标题页</title> <script language="javascript" type="text/javascript"> var today; var h; var m; var s; var clickCount=0; function tick(){
。试试<!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>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>无标题页</title>
<script language="javascript" type="text/javascript">
var today;
var h;
var m;
var s;
var clickCount=0;
function tick(){
today=new Date();
h=today.getHours();
m=today.getMinutes();
s=today.getSeconds();
if(h<10){h="0"+h}
if(m<10){m="0"+m}
if(s<10){s="0"+s}
document.getElementById('nowtxt').value=h+":"+m+":"+s;
a=setTimeout(tick,5000);
}
function createDiv(){
clickCount++;
var divObj=document.createElement('div');
divObj.style.width="100px"
divObj.innerHTML="当前序号:"+clickCount+"<br>"+"点击时间:"+document.getElementById('nowtxt').value;
if(clickCount%2!=0){
divObj.style.backgroundColor="yellow";
}
document.getElementById('contentDiv').appendChild(divObj);
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body onLoad="tick()">
<input type="text" id="nowtxt" style="width:100px" onclick="createDiv()">
<br>
<div id="contentDiv" style=" font-size:12px"></div>
</body>
</html>