2 回答
TA贡献1895条经验 获得超3个赞
MDN上有针对removeChild上可能造成的异常有解释:
The method throws an exception in 2 different ways:
If the child was in fact a child of element and so existing on the
DOM, but was removed the method throws the following exception:
Uncaught NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
If the child doesn't exist on the DOM of the page, the method throws
the following exception:
Uncaught TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'.
If child was in fact a child of element at the time of the call, but was removed by an event handler invoked in the course of trying to remove the element (eg, blur.)
添加回答
举报