Rahul
Rahul

Reputation: 3

Move div postion without touch - only PHP

I have

<div id="above">  Ram is good boy.   </div>
<div id="below">  Sita is good girl. </div>

I just want to change this html structure using php or jquery as follow without touching

<div id="below">  Sita is good girl. </div>
<div id="above">  Ram is good boy.   </div>

Upvotes: 0

Views: 800

Answers (1)

errand
errand

Reputation: 980

use jquery:

$("#below").after($("#above"));

the explanation: you have two divs - one with id="below", one with id="above".

first you set your reference to the div, that you want to hold in place:

$("#below")

then you have to tell jquery, what to do:

.after()

the jquery after function needs content to place behind the selected element (in your case #below). since you want the other element to be moved, you select this id.

$("#above")

put all together:

    $("#below").after($("#above"));

Upvotes: 4

Related Questions