<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
#div1
{float:left; width:100px; height:35px; margin:10px;padding:10px;border:1px solid #aaaaaa;}
#div2
{float:left; width:200px; height:100px; margin:10px;padding:10px;border:1px solid #aaaaaa;}
</style>
<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));
document.getElementById(data).width="200"
document.getElementById(data).height="100"
}
</script>
</head>
<body>
<form id="f1" name="form1" method="post">
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)">
<img src="smiley.png" draggable="true" ondragstart="drag(event)" id="drag1" width="88" height="31"></div>
<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
<input type="button" value="Clear" >
</form>
</body>
在这段代码中,当我删除图像时,我需要在单击清除按钮时从 div2 中删除图像。如何为此问题编写 javascript 代码。onclick 函数来编写我必须编写的代码。请帮我