焦点设置问题,有全部代码,急,在线等!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="mytable">
<tr>
<td width="18%"><div align="center"><a href="#" onClick="AddNew()">新增</a></div></td>
<td width="82%"> </td>
</tr>
<tr bgcolor="#FF0000">
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<script language="JavaScript">
function AddNew(){
var tr = mytable.insertRow(mytable.rows.length);
newCell1 = tr.insertCell(0);
newCell1.innerText="自动编号";
newCell2 = tr.insertCell(1);
newCell2.innerHTML="<input type='text' name='power_name'size='100' onFocus='getfocus()' size=30 maxlength=50>";
}
function getfocus(){
window.event.srcElement.style.background="ffff00";
window.event.srcElement.focus();
event.srcElement.select();
}
</script>
当按"新增"后text马上设置焦点和改变颜色。为什么这样不行呢?