how to add paragraph on top of div content

前端 未结 6 608
清酒与你
清酒与你 2020-12-09 15:28

How can I add multiple paragraph tag, newly tag on top within div container.

6条回答
  •  失恋的感觉
    2020-12-09 16:10

    A more elegant way without jQuery:

    var container = document.getElementById('pcontainer');
    container.insertBefore(document.createElement("p"), container.firstChild);
    

    This assumes there is already an element in the container btw.

提交回复
热议问题