Switch positions of 2 divs with jQuery

后端 未结 6 1632
遥遥无期
遥遥无期 2020-12-02 22:45

I\'m wondering if it\'s posible to switch positions of two divs with jQuery.

I have two div like this

STUFF ONE
6条回答
  •  独厮守ぢ
    2020-12-02 23:23

    var row2content = $('.div2').html();                //Get row 2s content
    row2contentnospaces = row2content.replace(' ', ''); //Eliminate whitespace
    if(!(row2contentnospaces == '')){                   //Check if row2 is empty
        var row2 = $('.div2');                          //Get row 2
        $('.div2').remove();                            //remove row2
        $('.div1').before(row2);                        //add row 2 before row 1
    }
    

提交回复
热议问题