jquery reorder divs

前端 未结 4 578
旧巷少年郎
旧巷少年郎 2021-01-04 20:59

I have 3 divs want to reverse the order on doucment ready

First
Second
4条回答
  •  有刺的猬
    2021-01-04 21:49

    This will reverse all divs inside a div with id "div1"

      $(function(){
        var items=$("#div1 div").toArray();
            items.reverse();
            $.each(items,function(){
               $("#div1").append(this); 
            });     
        });​
    

    Here is the jsFiddle http://jsfiddle.net/bCAVz/8/

提交回复
热议问题