我试图在点击一个按钮时删除一行。它工作正常,除非我在一个表内。我的JSP在表中有50行的组合,之后我们嵌套这些表。现在,我的问题是如果我想删除上一个表中的最后一行,我应该怎么做?使用JavaScript删除节点
我附上UI和调试器HTML视图的屏幕截图。任何建议都会有所帮助。
[DROW]这里是我们有一个树结构的不同行。我们需要首先爬到每一行,然后向下移动到lastChild以删除最后一行。
这是唯一可能的,如果我的previousRow包含最后一行val。我无法理解它。
function removeAnotherResponse(arg0, data, response, request){
// Make sure the response has everything we need
if(arguments==null || arguments.length<4 || !request.content || request.content==null || !request.content.groupUniqueId || request.content.groupUniqueId==null){
return;
}
// Check for true response
if(!data || data==null || !data[0] || !data[0].removedSuccess || data[0].removedSuccess!=true){
return;
}
var groupUniqueId=request.content.groupUniqueId;
// Get the add another button row and add the new row before it.
var addAnotherRow=document.getElementById("ADD_"+groupUniqueId);
if(addAnotherRow==null) return;
var previousRow=document.getElementById("ADD_"+groupUniqueId).previousSibling;
addAnotherRow.parentNode.removeChild(previousRow);
showOrHideAddRemoveButtons(groupUniqueId, data[0].removeButton, data[0].addButton);
updateSectionCount(groupUniqueId, false);
getPortCount(groupUniqueId);
}
添加代码不是截图。 – Mritunjay 2014-08-31 13:02:10
@Mritunjay ..我添加了我用来删除表内行的代码。我无法移动到上面嵌套了表格的行,如调试屏幕截图所示。 – Bhaskar 2014-08-31 13:05:41
'id'属性值应该是每个元素唯一的。在这里你应该使用不具有相同值的'id'类。 – GillesC 2014-08-31 13:14:16