$.fn.draggable = function() {
return $.each(this, function() {
var $el = $(this);
var move = function(e) {
if(!$el.data("_isMove")) return;
var pos = $el.data("pos"),
pos = { x: parseInt($el.css("left")) + (e.clientX - pos.x),
y: parseInt($el.css("top")) + (e.clientY - pos.y) };
$el.css({ top: pos.y, left: pos.x });
$el.data("pos", { x: e.clientX, y: e.clientY });
};
$el.on("mousedown", function(e) {
var $this = $(this);
$el.data("_isMove", true);
$el.data("pos", { x: e.clientX, y: e.clientY });
});
$el.on("mouseup mouseout", function(e) {
$el.data("_isMove", false);
});
$el.mousemove(move);
});
};
$("#object1, #object2, #object3").draggable();