jQuery move div from position 1 to 2

Viewed 29349

I have multiple divs (haveing same class names). I want to move the div (always same div, which has unique ID #pos1) to the div which has been clicked. So, for that purpose, I am using following code to find the position1 (of the div which I want to move) and pos2 (the div which is clicked).

However, I don't know know how can I move (animate etc) the div from one position to another. I will appriciate any help.

jQuery(".container").click(function() {

    var pos1 = jQuery("#pos1").position();
    alert(pos1.top + ', ' + pos1.left);

    var pos2 = jQuery(this).position();
    alert(pos2.top + ', ' + pos2.left);

});
2 Answers
Related