对于 table 添加行有专门的处理方法:
var b = document.getElementById('tableId');
var tr = b.insertRow(b.rows.length);
tr.id = "id2";
tr.onclick = function(){alert('hello');}var td = tr.insertCell(tr.cells.length);
td.width = 25;
td.height= 20;
td.innerHTML = " "+ '2.';
var b = document.getElementById('tableId');
var tr = b.insertRow(b.rows.length);
tr.id = "id2";
tr.onclick = function(){alert('hello');}var td = tr.insertCell(tr.cells.length);
td.width = 25;
td.height= 20;
td.innerHTML = " "+ '2.';
解决方案 »
- 高分请教一个有关冲突问题,在线等!
- 如何通过DIV本身引用其内的其他标签
- 这种情况应该怎么做呢
- 获取客户端OS登陆用户名
- 一个函数两种方式调用,不一样的效果?一种可以全屏,一种不可以全屏!应该怎么解决这个问题?(用Chrome浏览器)
- JS里的提示框,除了alert还有什么?
- 帮助看一下巴
- 如何新建一个窗口a,并同时关闭已经存在窗口b,或者
- 在不同的FRAME中动态添加SELECT的OPTION,怎么做?100分
- 调用js时,系统总提示'jQuery' 未定义,怎么办
- 实现的功能,每隔4秒弹出一个窗口,同时关闭上一个窗口,即打开a2,关闭a1,打开a3,关闭a2
- 哪位高手研究过msn相册另类上传的代码
tr.onmouseover = function(){this.style.backgroundColor="#EEEEEE";}
tr.onmouseout = function(){this.style.backgroundColor="";}
tr.style.backgroundColor = "#FFFFFF";
tr.style.fontSize = "12px";
<tbody id="tbodyList">
<tr valign="middle" id="id1" style="background-color:;color:#000000;font-szie:12px;cursor:hand;" onClick="javascript:abc();" onMouseOver="this.style.backgroundColor='#EEEEEE';" onMouseOut="this.style.backgroundColor='';">
<td width="25" height="20" align="left"> 1.</td>
<td width="125" align="left">我等到的花儿也谢了-</td>
</tr>
</tbody>
</table>
<script language="javascript">
b = document.getElementById('tbodyList'); var tr = document.createElement('<tr id=id2 onmouseover="this.style.backgroundColor=\'#eeeeee\';" onmouseout="this.style.backgroundColor=\'\';" '
+ ' onclick="alert(\'\');" style="background-color:#000000;color:#000000;font-szie:12px;cursor:hand;">');
var td = document.createElement('<td width=25 height=20 align=left>');
td.innerHTML =' ' + '2.';
var td2 = document.createElement('<td width=25 height=20 align=left>');
//td2.innerHTML ="名字";
td2.appendChild(document.createTextNode("名字"));
tr.appendChild(td);
tr.appendChild(td2);
b.appendChild(tr);
</script>