问题
I created a nested tree using XUL (no database was used to store items). I want to delete items from this tree by selecting the item (only 1 at a time) then click delete. I wrote Javascript function to delete as following but it does not work.
function delete(){
var tree = document.getElementById("treeId");
currentPos = tree.currentIndex;
var currentItem = tree.contentView.getItemAtIndex(currentPos);
var parent = currentItem.getParent();
parent.removeChild(currentItem);
}
I guess getParent() is not the right method but did not find any other method. Can someone give me some hints please. Thanks
回答1:
Problem solved. It was my mistake. I just realized that delete cannot be used as a name of function.
来源:https://stackoverflow.com/questions/3791433/how-can-i-delete-item-from-a-nested-xul-tree