Move a .class to a desired position using jquery
<div id="2" class="h">two</div>
<div id="3" class="h">three</div>
<div id="4" class="h">4</div>
<div id="5" class="h">5</div>
When I click on 5 I want it to move to t开发者_如何学Che position where id=3 is, using jQuery.
Thanks Jean
First of all, id's cannot start with a number, so I don't know how jQuery will react, but this should do it:
$('#5').click(function() {
$('.h').eq(1).after($(this));
});
That would move #5 between #2 and #3 when clicked upon.
精彩评论