javascript - Why is it useless to insert a child node before this label after CreateElement?
高洛峰2017-06-17 09:16:50
0
2
778
Document
The last sentence oUl.insertBefore(oLi,oLi[0]); Why can’t I choose to insert at oLi[0]? I want it to be inserted at the front every time I click? Instead of creating a li every time you click, and then inserting it before the 0th index, it should be no problem.
The second parameter indicates inserting newnode before this node. If it is null or undefined, the insertBefore method will add newnode to the end, which has the same effect as appendChild
The second parameter indicates inserting newnode before this node. If it is null or undefined, the insertBefore method will add newnode to the end, which has the same effect as appendChild