i am learning the drag and drop program in html, and i tried the below code.
<html>
<head>
My head
<script>
function dragme(event)
{
event.dataTransfer.setData("sourceID", event.target.id);
}
function dropHere(event)
{
event.preventDefault();
alert ("inside drop Here..");
}
function dropOver(event)
{
console.log ("inside drop Over..");
}
</script>
<style>
div {width:500px;height:400px;border-color:red;border-style:solid;}
</style>
</head>
<body>
<div id="sourcedrag" ondrop="dropHere(event)" ondragover="dropOver(event)">
inside div
</div>
<button draggable=true id="button" ondragstart="dragme(event)" >Press me </button>
<button draggable=true id="button1"> Second Press me </button>
<button draggable=true id="button2"> Second Press me </button>
<button draggable=true id="button3"> Second Press me </button>
<button draggable=true id="button4"> Second Press me </button>
</body>
</html>
Unfortunately, the alert box inside dropHere is not getting invoked. But dropOver console message is getting printed. What am i doing wrong?