Parent and Child DIV's not nested position change jquery javascript question -
if have 2 divs, div , div b (assume both absolute positioned).. want amke when div a's position changes, div b (which "child" of div a, event though 2 separate divs, not nested), div b's position changes same offsets div did. if move div b's position... div b moves , div a's position unaffected.
change in positon dragging div example.
if possible, able make can have 3rd div, , "child" of div or b, , same action apply. (ex1. if div c , b children of div a, moving div update position of div c , b)
ex2. if div c child of div b, when moving diva, div b , c updated. if divb moved, div b , c updated. if moving div c, div c updated.
update: hussein's code similar want, problem div of class .b happens snap opposed preserving current position , adding offset .a moves.
assuming using jquery ui draggable()
, use drag event achieve this. may need modify code further suit needs, example below should on right track.
$('.a, .b').draggable({ drag: function(event, ui) { $('.a').css({ top: ui.offset.top + 'px', left: ui.offset.left + 100 + 'px' }) } });
Comments
Post a Comment