Safeer008 Posted October 14, 2014 Share Posted October 14, 2014 I want to swap two divs. <div> <div id="div1">Div One</div> <div id="div2">Div Two</div> </div> I want the result as follows: <div> <div id="div2">Div Two</div> <div id="div1">Div One</div> </div> Please help me. Thanks. Link to comment Share on other sites More sharing options...
Ingolme Posted October 14, 2014 Share Posted October 14, 2014 Use the removeChild(), appendChild() and insertBefore() methods to move the nodes around. Link to comment Share on other sites More sharing options...
dustcomposer Posted October 15, 2014 Share Posted October 15, 2014 You can also do the longer way with an array of divs: example at fiddle. Link to comment Share on other sites More sharing options...
davej Posted October 15, 2014 Share Posted October 15, 2014 I want to swap two divs. Why? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now