Move an element one place up or down in the dom tree with javascript

后端 未结 4 1296
深忆病人
深忆病人 2021-01-31 03:15

I want a javascript way to move an element one place up or down in the dom tree within a particular known parent using javascript (or jquery is ok), but i want the script to kno

4条回答
  •  无人共我
    2021-01-31 03:55

    Get all the child div with parent div id (#parent_div) using $.each function of jQuery. suppose you want to swap div3 with div2, then index of div3 will be 2. use $(#div_3).insertBefore(#div_2)

提交回复
热议问题