0

I have an element object and it has some children appended to it via the appendChild(Node) method,I know I can access them with element.childNodes[index].

Now if I remove some element from it by selecting them by their id will the element at index i+1 be at index i if I removed the one at index i?

Secondly is there a way to remove the object from the array only by specifying the indices via some built in method to achieve a linked list like behaviour(i mean without having to copy the elements from their index to a prior index when i remove one that was prior to them)?

4

1 回答 1

1

1) 是的

2)尝试Array.splice

> a = [0,1,2,3,4,5]
[0, 1, 2, 3, 4, 5]
> a.splice(3, 1)
[3]
> a
[0, 1, 2, 4, 5]

不知道是否ArraysNodeLists用链表或其他东西实现。取决于我猜的引擎。

于 2013-04-25T10:10:14.403 回答