Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法在div中删除文本_Javascript_Html - Fatal编程技术网

Javascript 无法在div中删除文本

Javascript 无法在div中删除文本,javascript,html,Javascript,Html,今天我做了一些html5的拖放功能。我遇到的问题是,当我试图从一个div拖放一个图像到另一个div时,Firefox中没有这样做。让我们看看下面给出的代码 <!DOCTYPE html> <html> <head> <title>Setting the Drop area</title> <script type="text/javascript"> function Drop(event)

今天我做了一些html5的拖放功能。我遇到的问题是,当我试图从一个div拖放一个图像到另一个div时,Firefox中没有这样做。让我们看看下面给出的代码

<!DOCTYPE html>
<html>
<head>
    <title>Setting the Drop area</title>
    <script type="text/javascript">
        function Drop(event)
        {
            var oDiv=document.getElementById("text1");
            oDiv.value+=event.type+"\n";
            switch (event.type)
            {
                case "dragover":
                case "dragleave":
                    event.returnValue=false;
                case "dragenter":
                        event.returnValue=false;
            }
        }
    </script>
</head>
<body>
<h3>Drag the image from one div to another div</h3>
<div id="div1" style="border: 2px solid black; width: 200px; height: 200px; position: relative">
    <img src="mine,image,life,quote,words,message-5eb746364548d71d07c86e52e63b7b56_h.jpg" width="100px" height="100px" ondragstart="Drop(event)" ondrag="Drop(event)" ondragend="Drop(event)">

</div>
<div id="div2" style="border: 2px solid black; width: 200px; height: 200px; position: relative; display: block; float: right"
        ondragenter="Drop(event)" ondragover="Drop(event)" ondragleave="Drop(event)" ondrop="Drop(event)">

</div>
<div style="border: 1px solid black; position: relative; clear: both">
    <textarea id="text1" rows="20" cols="30"></textarea>
</div>

</body>
</html>

设置放置区域
函数删除(事件)
{
var oDiv=document.getElementById(“text1”);
oDiv.value+=event.type+“\n”;
开关(事件类型)
{
案例“dragover”:
案例“dragleave”:
event.returnValue=false;
案例“dragenter”:
event.returnValue=false;
}
}
将图像从一个div拖动到另一个div

请让我知道此代码的问题所在

将断路器添加到您的开关箱中,并选中文本框:

代码:

<!DOCTYPE html>
<html>
<head>
    <title>Setting the Drop area</title>
    <script type="text/javascript">
        function Drop(event)
        {
            var oDiv=document.getElementById("text1");
            oDiv.value+=event.type+"\n";
            switch (event.type)
            {
                case "dragover":
                case "dragleave":
                    event.returnValue=false;
                case "dragenter":
                        event.returnValue=false;
            }
        }
    </script>
</head>
<body>
<h3>Drag the image from one div to another div</h3>
<div id="div1" style="border: 2px solid black; width: 200px; height: 200px; position: relative;float:left;">
    <img src="mine,image,life,quote,words,message-5eb746364548d71d07c86e52e63b7b56_h.jpg" width="100px" height="100px" ondragstart="Drop(event)" ondrag="Drop(event)" alt="5eb746364548d71d07c86e52e63b7b56_h" ondragend="Drop(event)"/>

</div>
<div id="div2" style="border: 2px solid black; width: 200px; height: 200px; position: relative; display: block; float: right"
        ondragenter="Drop(event)" ondragover="Drop(event)" ondragleave="Drop(event)" ondrop="Drop(event)">

</div>
<div style="border: 1px solid black; position: relative; clear: both">
    <textarea id="text1" rows="20" cols="30"></textarea>
</div>

</body>
</html>

设置放置区域
函数删除(事件)
{
var oDiv=document.getElementById(“text1”);
oDiv.value+=event.type+“\n”;
开关(事件类型)
{
案例“dragover”:
案例“dragleave”:
event.returnValue=false;
案例“dragenter”:
event.returnValue=false;
}
}
将图像从一个div拖动到另一个div

好吧,您可以从添加
中断开始到您的交换机。