Animate DIV to another DIV position -
i can't figure out how animate div goes #slot1 position (and later slot choose).
here javascript code , fiddle
$(function (){ $('#deck').click(function (){ var slotpos = $('#slot1').position(); $(this).animate({left: slotpos.left}, 400); }); });
thanks in advance!
$(#slot1 ).position()
function giving relative position w.r.t to
<div id='head'>
container. can try below code. , use accordingly it:
$(function (){ $('#deck').click(function (){ var slotpos = $('#slot1').position(), hand=$("#hand").position(); $("#deck").animate({ left: 10+hand.left+slotpos.left, top:10 + hand.top}, 400); }) } );
let me know if works you!