function InsertRow(id)
{
var thisRow = event.srcElement.parentNode.parentNode;
var nextRow = thisRow.nextSibling;
if (typeof(thisRow.flag)=="undefined" || !thisRow.flag) {
var tr = table2.insertRow(thisRow.rowIndex + 1);
var td = tr.insertCell();
td.colSpan = 5;
var str = Proj.Table_Pass.GetDetail(id).value;
td.innerHTML = str;
thisRow.flag = true;
} else {
table2.deleteRow(thisRow.rowIndex + 1);
thisRow.flag = false;
}
} <table class="list" id="table2" cellSpacing="1" width="100%" align="left" border="0">
<tr>
<td width="30%" align="left" valign="middle">
<a href="#" onclick="InsertRow('130000');">河北省 </a>
</td>
<td width="30%" align="left" valign="middle">
<a href="#" onclick="InsertRow('140000');">山东省 </a>
</td>
</tr>
</table> 当我单击河北省的时候 我想在河北省的下一行 也就是山东省的上面动态添加行
这个代码能运行,但是有时候添加的行却在"河北省"这行的上面(也就是最上面一行 无论点击哪行 都有时候会跑到最上面一行) 请问这是怎么回事?谢谢
{
var thisRow = event.srcElement.parentNode.parentNode;
var nextRow = thisRow.nextSibling;
if (typeof(thisRow.flag)=="undefined" || !thisRow.flag) {
var tr = table2.insertRow(thisRow.rowIndex + 1);
var td = tr.insertCell();
td.colSpan = 5;
var str = Proj.Table_Pass.GetDetail(id).value;
td.innerHTML = str;
thisRow.flag = true;
} else {
table2.deleteRow(thisRow.rowIndex + 1);
thisRow.flag = false;
}
} <table class="list" id="table2" cellSpacing="1" width="100%" align="left" border="0">
<tr>
<td width="30%" align="left" valign="middle">
<a href="#" onclick="InsertRow('130000');">河北省 </a>
</td>
<td width="30%" align="left" valign="middle">
<a href="#" onclick="InsertRow('140000');">山东省 </a>
</td>
</tr>
</table> 当我单击河北省的时候 我想在河北省的下一行 也就是山东省的上面动态添加行
这个代码能运行,但是有时候添加的行却在"河北省"这行的上面(也就是最上面一行 无论点击哪行 都有时候会跑到最上面一行) 请问这是怎么回事?谢谢
解决方案 »
- 请教一下关于post编码的问题。
- opener.top
- 想做一个学习用的个人网站
- 使用jquery实现内容进度显示的进度条
- 论ie和firefox(mozila)中获取事件对象方式的异同-(绝对原创)
- 急求怎么让网页中的浮动广告层在最上面
- 求代码,类似使用js脚本实现的跳动的时间。
- form的enctype的问题(在线等待)
- 在包含多个Iframe的页面中分别打印每个iFrame里的src的页面
- Ext4.2:ScriptTagProxy到4.2中不可用了,求解
- 麻烦大家帮我看看javascript部分 不太明白!!!!
- [向大家提问]Function.prototype.apply.apply是什么东东??有分会补上~
insertRow(index);
index: -1.默认添加到最后一行
index: 0.第一行 1第二行 ...