Example HTML :
<h2 class="x1">1</h2>
<h2 class="x2">2</h2>
<h2 class="x3">3</h2>
<h2 class="x4">4</h2>
<h2 class="x5">5</h2>
I want to switch like...
1
2 <---
3 |
4 |
5 <---
So I do like this
$('.x2').insertBefore('.x5');
$('.x5').insertBefore('.x2');
So I get result like this
1
3
4
5 <---
2 <---
How can I get result like... ?
1
5 <---
3 |
4 |
2 <---
Playground : http://jsfiddle.net/l2aelba/aHwSJ/
PS : If possible I dont want to do like
$('.x2').insertBefore('.x5');
$('.x5').insertBefore('.x3');
I need to select element only 2 elements (NOT ANOTHER)