At this point, the drag3
always returns the initial position, except when it is placed in drop1
. In the complete game there are 4 drag's and 4 drop's but just 1 of each for the example and to give an understanding how I have this, I think.
What I really want, as I said, is to return all the drag's initial position without refreshing the page (which is what I do in this example) when I click on the restart button.
$("#drag3").draggable({
revert: true,
containment: "#fundo-interno"
});
$("#drop1").droppable({
drop: function(event, ui) {
if (ui.draggable.attr('id') == 'drag3') {
$("#drag3").draggable({
revert: false,
containment: "#fundo-interno"
});
$(this)
.addClass("alterar1")
.find("p")
alert("Muito Bem !");
} else {
$(this)
.find("p")
alert("Tenta denovo !");
}
}
});
#drag3 {
float: left;
margin-left: 75px;
margin-top: 25px;
background-color: #727170;
width: 45px;
height: 45px;
}
#drop1 {
float: left;
margin-left: 20px;
margin-top: 9px;
width: 210px;
height: 180px;
float: left;
background-position: center;
border: 1px solid grey;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script><scriptsrc="https://code.jquery.com/ui/1.11.3/jquery-ui.min.js"></script>
<link href="https://code.jquery.com/ui/1.11.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<input type="reset" name="recomecar" value="Ok" id="recomecar" onclick="window.location.reload( true );">
<img src="seta.png" width="100px" height="100px">