1
I have a drag-and-drop problem. I have two Ivs, one with images that will be played to another div that has 1 specific image that cannot be moved. But when I drop on an image (both specific and other) the image disappears, it is food. I ask for your help in solving this problem. Follow the codes>
<body>
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="bloco0.png">
</div>
<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)">
<image id="5" class = "bloco" src="bloco1.png" draggable="true" ondragstart="drag(event)">
<image id="6" class = "bloco" src="bloco2.png" draggable="true" ondragstart="drag(event)">
<image id="7" class = "bloco" src="bloco3.png" draggable="true" ondragstart="drag(event)">
<image id="8" class = "bloco" src="bloco4.png" draggable="true" ondragstart="drag(event)">
</div>
<script type="text/javascript" src="js/main.js"></script>
<script>
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}
</script>
</body>
MY FRIEND THANK YOU VERY MUCH YOU JUST SAVED MY JOB!!
– Lucas Pires