Reordering of Divs

后端 未结 6 779
轮回少年
轮回少年 2020-12-03 01:23

How would I go about reordering divs without altering the HTML source code?

example, I want divs to appear in order #div2, #div1, #div3, but in the HTML they are:

6条回答
  •  青春惊慌失措
    2020-12-03 01:59

    In jQuery, you can do the following:

    $("#div1").insertAfter("#div2");
    

    That will move the element with id 'div1' to after element with id 'div2'. This assumes that you eliminate the '#' from your id attributes.

提交回复
热议问题