How to create new div dynamically, change it, move it, modify it in every way possible, in JavaScript?

后端 未结 2 1663
予麋鹿
予麋鹿 2020-12-02 03:46

I want to create new divs as the page loads. These divs will appear as an ordered group which changes depending upon external data from a JSON file. I will need to do this w

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 04:07

    Have you tried JQuery? Vanilla javascript can be tough. Try using this:

    $('.container-element').add('
    Insert Div Content
    ');

    .container-element is a JQuery selector that marks the element with the class "container-element" (presumably the parent element in which you want to insert your divs). Then the add() function inserts HTML into the container-element.

提交回复
热议问题