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));
}
<div class = “container”>
<div class = “row” >
<div class="col-md-1 center">
<img src="https://i.sstatic.net/vxnww.jpg" style="height: 250px">
</div>
<div class="col-md-1">
<div class="boxFirstCol" id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"> </div>
<p><b>4s</b></p>
<div class="box"> </div>
<p><b>3s</b></p>
<div class="box"> </div>
<p><b>2s</b></p>
<div class="box"> </div>
<p><b>1s</b></p>
</div>
</div>
</div>
The functionality of this code allows users to drag electrons into the designated boxes and upon dropping them, they disappear from the box.