- 爱易网页
-
JavaSript
- 麻烦大家修改下实例中的BUG?该怎么解决
日期:2014-05-16 浏览次数:20472 次
麻烦大家修改下实例中的BUG?
这是我从网上找的个实例:但是有很明显的BUG,就是当把某单元格的退格为空时,移开焦点,发现此刻除了文本框消失外,所在的单元格也同时消失了;我肯定希望此是该单元格不消失,如何修正这个BUG呢?请各位朋友指点?多谢!
<title> 编辑表格 </title>
<style type= "text/css ">
<!--
body { font-size:12px;}
input {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #666;
background-color: #FFFFE1;
border: 1px solid #999;
height:auto;
}
.Table { border-width:1px 0px 0px 1px; border-style:solid; border-color:#999;}
.Table td { border-width:0px 1px 1px 0px; border-style:solid; border-color:#999;}
-->
</style>
</head>
<body>
<table width= "80% " border= "0 " cellpadding= "0 " cellspacing= "0 " onclick= "setEdit(event.srcElement) " class= "Table ">
<tr>
<td width= "17% "> a </td>
<td width= "19% "> bb </td>
<td width= "30% "> asdf </td>
<td width= "23% "> eee </td>
<td width= "11% "> adsf </td>
</tr>
<tr>
<td> 1 </td>
<td> 3 </td>
<td> 4 </td>
<td> 5 </td>
<td> 9 </td>
</tr>
<tr>
<td> as </td>
<td> asdfsdfa </td>
<td> sadfsdaf </td>
<td> sadfsdfa </td>
<td> sdafsadf </td>
</tr>
<tr>
<td> sadfsdfa </td>
<td> asdf </td>
<td> </td>
<td> asdfasdf </td>
<td> asdfasf </td>
</tr>
<tr>
<td> asdfsadf </td>
<td> asdfsadf </td>
<td> asdfasdfasd </td>
<td> ea </td>
<td> asdfasfd </td>
</tr>
</table>
</body>
</html>
<script type= "text/javascript ">
oldObj= " ";
var newNode=document.createElement( "input ");//创建text文本框表单对象
newNode.type= "text ";
function setEdit(click_td)//click_td是事件发生对象
{
var obj;
if(click_td.tagName== "TD ")//如果事件是发生在单元格上时;