There're 2 element div which are two mode of a table (side-table and center-table). When user drag and drop center-table on left area then it would turn into side-table and vice-versa.
Here I use js to get id of draged element and id of droped element then set their opacity to 0 and 1. But browser can't get id of elements. What's the problems or is there any another way to do this? [side-table][https://drive.google.com/file/d/1GM5eA-AevwqKpYKCGe7vld3OMtRJnvXE/view?usp=sharing]
[demo video][https://drive.google.com/file/d/1O8FbfRNudlgdsI_l3cGKqeSmSch03FTN/view?usp=sharing]
<div class="control-bar" ondragover="allowDrop(event)" ondrop="drop(event)">
<div class="sidebar" draggable="true" id="sidebar" ondragstart="drag(event)"></div>
</div>
<div class="centre" ondragover="allowDrop(event)" ondrop="drop(event)">
<div class="wrapper" id="wrapper" draggable="true" ondragstart="drag(event)"></div>
</div>
With js:
function allowDrop(e) {
e.preventDefault();
}
function drag(e) {
e.dataTransfer.setData("text", e.target.id);
}
function drop(e) {
e.preventDefault();
var data = e.dataTransfer.getData("text");
document.getElementById(data).style.opacity = "0";
console.log(e.target.id);
document.getElementById(e.target.firstChild).opacity = "1";
}