How to move two divs upqwards in the dom using jquery? -


i not sure how this. have following code:

<div class="one">you might invite...</div> <div class="pic1"></div> <div class="name1">some name</div> <div class="pic2"></div> <div class="name2">another name</div> <div class="pic3"></div> <div class="name3">third name</div> 

now, want is, 1 event, want divs class pic2 , name2 jump position in code, this:

<div class="pic2"></div> <div class="name2">another name</div> <div class="one">you might invite...</div> <div class="pic1"></div> <div class="name1">some name</div> <div class="pic3"></div> <div class="name3">third name</div> 

how should achieved? should using "prepend"? or have recurse through dom , reposition them...

thanks

jsfiddle demo

you use insertbefore()jquery api

$('.pic2').insertbefore('.one'); $('.name2').insertbefore('.one'); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -