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.

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all (2)
小葫芦
node.insertBefore(newnode,existingnode);

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

oLi[0]值为undefined
    黄舟
    location.href = "../exit.html"; throw new Error('stop');
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!