日期:2014-05-16 浏览次数:20403 次
<!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">
//去除底部的广告
function clearGG(){
var ps=document.getElementsByTagName("p");
ps[ps.length-1].style.visibility="hidden";
}
//改变单元格的背景色
function setBgColor(tddom) {
tddom.style.backgroundColor="red";
}
//去除背景色
function clearBgColor(tddom) {
tddom.style.backgroundColor = "";
}
//为所有的td绑定事件
function binding() {
var inputs = document.getElementsByTagName("input");
for (i = 0; i <inputs.length; i++) {
if (inputs[i].getAttribute("type") == "text") {
//获得文本框的父节点td
var tdp = inputs[i].parentNode;
//为text文本框的得到焦点事件绑定方法
inputs[i].onfocus = function () { setBgColor(tdp); };
//为text文本框的失去焦点事件绑定方法
inputs[i].onblur = function () { clearBgColor(tdp); };
}
}
//去掉广告
clearGG();
}
</script>
</head>
<body onload="binding()">
<form name="form1" action="">
<table border="2" cellpadding="5" cellspacing="5">
<tbody>
<tr>
<td>编号</td>
<td id="t1"><input type="text" name="txtbian" /></td>
<td >名称</td>
&n