tags:

views:

13

answers:

1

Hello,

<div id="1" class="h">one</div>
<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 the position where id=3 is, using jQuery.

Thanks Jean

+2  A: 

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.

Tatu Ulmanen
assuming #id is random, this would not work
Jean
No such assumption was clear from your question. I've edited my answer.
Tatu Ulmanen
sorry.but modified your answer w.r.t my code, it worked....Thanks.....
Jean