Reputation: 31
I followed this tutorial on YT https://www.youtube.com/watch?v=8vs-SF2UWy4&t=28s Sorry in advance if I made any mistakes here, I just started learning but I have to make draggable and droppable furniture I can't move the objects
here are the code that I wrote
<div class="wrap">
<div id="home">
<div class="image"><img src="A.png" width="200px" alt=""></div>
<div class="image"><img src="B.PNG" width="240px" alt=""></div>
<div class="image"><img src="C.PNG" width="250px" alt=""></div>
<div class="image"><img src="D.PNG" width="210px" alt=""></div>
<div class="image"><img src="E.PNG" width="290px" alt=""></div>
<div class="image"><img src="F.PNG" width="240px" alt=""></div>
<div class="image"><img src="G.PNG" width="250px" alt=""></div>
<div class="image"><img src="H.PNG" width="220px" alt=""></div>
</div>
</div>
<script scr="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css"></script>
<script type="text/javascript">
$(function (){
$("#home .image").draggable();
});
</script>
Upvotes: 0
Views: 133
Reputation: 948
See working example in snippet. You need to include jQuery
before jQuery UI
.
$(function (){
$(".image").draggable();
});
.image {
background:yellow;
width:200px;
height:200px;
margin-bottom:1rem;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<div class="wrap">
<div id="home">
<div class="image"></div>
<div class="image"></div>
<div class="image"></div>
<div class="image"></div>
<div class="image"></div>
<div class="image"></div>
<div class="image"></div>
</div>
</div>
Upvotes: 2