我的助推器選項卡中有3個表格。每個選項卡作爲表格。該表的行是使用csharp asp.net代碼動態生成的。正確的我想要一個場景是,如果用戶單擊第一個表的行,第一個表的clicked角色將從第一個表中移除並添加到第二個表的行中。嘗試使用javascript去除子元素html元素
我的挑戰是在onClick過程之後開始刪除行。
<tbody>
<tr id="[email protected]">
<td> kayode <a class="chat" connectionid="135976e6-799b-4cda-a764-a00f7110d515"
data-parentid="[email protected]"
href="/Visitor/StartChat?threadid=3&email=kayode%40yahoo.com"
operatorid="1" target="_blank" threadid="3">chat</a></td>
<td>271.0.0.1</td>
<td>Active</td>
<td></td>
<td>9/13/2014</td>
<td>04:15:18</td>
<td>02:52:55</td>
<td>271.0.0.1</td>
</tr>
</tbody>
我的JavaScript代碼,我試圖用來刪除Click事件後的行。
function updateWaitingState(sender) {
var parentid = $(sender).attr("data-parentid");
//alert(parentid);
//we are going to remove the role from this field
var element = document.getElementById(parentid);
element.parentNode.removeChild(element); //This line is a problem says
//document.querySelector("tablebody4 first").appendChild(element);
console.log(element);
}
爲什麼混合使用jQuery和純DOM API?看起來你的需求可以簡單地通過'$('#table1')。on('click','tr',function(){$(this).appendTo('#table2');});' – rhgb 2014-09-13 14:27:53
watch這些免費的教程學習jquery請http://code.tutsplus.com/courses/30-days-to-learn-jquery – 2014-09-13 15:25:07
順便說一句,只有一行你想要該行被刪除。 – 2014-09-13 15:25:43