I am trying to make a div movable. The div has child div elements. You can check out the jsfiddle here : http://jsfiddle.net/TsW5F/2/
I want only the container (out most div) to be movable. Currently the inner text is movable without the outer div. The outermost container div should always move along with the rest of the child elements.
<div id="id">
<div>second div</div>
<div>third element</div>
</div>
$(document).ready(function() {
var $dragging = null;
$(document.body).on("mousemove", function(e) {
if ($dragging) {
$dragging.offset({
top: e.pageY,
left: e.pageX
});
}
});
$('#id').on("mousedown", null , function (e) {
$dragging = $(e.target);
});
$(document.body).on("mouseup", function (e) {
$dragging = null;
});
});