I have an image (small circle) that I want to drag on top of another bigger image (an axis). How do I set the bigger image as the parent to contain the circle?
Below is what I tried, but the circle cannot be dragged on top of the entire big image, it only drags vertically.
Code:
$(function() {
$("#draggable").draggable({
containment: "#container",
scroll: false
});
});
#draggable {
position: relative;
left: 20px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.2/jquery-ui.min.js"></script>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Drag a dot</title>
</head>
<body>
<div id="container">
<img src="https://ka-perseus-graphie.s3.amazonaws.com/ed9ce4eb0526f1c335eaea9b3a1920232455ec57.png" style="width:304px;height:228px">
<div id="draggable">
<img src="http://www.cmjc.ca/images/ferme.png" style="width:15px;height:15px">
</div>
</div>
</body>
</html>