当前位置:网站首页>拖放
拖放
2022-06-26 02:49:00 【小菜鸟码住】
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
#box{
width: 300px;
height: 300px;
border: 3px solid red;
}
</style>
</head>
<body>
<img id="img" src="img/musicBtn.png" alt=""/>
<div id="box">
</div>
<script>
var img = document.getElementById('img');
var box = document.getElementById('box');
img.ondragstart = function(e){
console.log(1);
e.dataTransfer.setData('text',this.id);
}
box.ondragover = function(e){
e.preventDefault();//取消默认事件处理
}
box.ondrop = function(e){
var txt = e.dataTransfer.getData('text');
// console.log(txt);
box.appendChild(document.getElementById(txt));
// img.parentNode.removeChild(img);
// box.innerHTML += '<img src="'+txt+'">';
}
</script>
</body>
</html>


边栏推荐
- 虫子 构造与析构
- Dreamcamera2 video recording, playing without sound, recording function is normal, using a third-party application for video recording, playing with sound
- Fresh graduates talk about their graduation stories
- ORB-SLAM系列论文翻译笔记
- 丝网印刷的种类及其应用方法
- Is it safe to open an online stock account?
- Clion项目中运行多个main函数
- Problems encountered in project deployment - production environment
- Is it safe to open an account in flush online? How to open a brokerage account online
- 双碳红利+基建大年 | 图扑深耕水利水电绿色智能装备领域
猜你喜欢

工作室第3次HarmonyOS培训笔记

Little p weekly Vol.10

应届毕业生谈毕业的故事

QT compilation error: unknown module (s) in qt: script

How to add a regression equation to a plot in R

使用IDEA画结构图

Qt编译出错ERROR: Unknown module(s) in QT: script

经典模型——ResNet

Good news | congratulations on the addition of 5 new committers in Apache linkage (incubating) community

如何提词条
随机推荐
Learn Tai Chi Maker - mqtt (IV) server connection operation
[machinetranslation] - Calculation of Bleu value
Oracle exercise
计组笔记——CPU的指令流水
GD32 ADC采集电压
Leetcode 176 The second highest salary (June 25, 2022)
MySQL updates records based on the queried data
Components and routing
Is it safe to open an online stock account?
Stm32cubemx: watchdog ------ independent watchdog and window watchdog
How to add a table to a drawing in ggplot2
Vulhub replicate an ActiveMQ
Inkscape如何将png图片转换为svg图片并且不失真
【论文笔记】Learning to Grasp with Primitive Shaped Object Policies
【解决】CMake was unable to find a build program corresponding to “Unix Makefiles“.
The difference between like,%, - in database query SQL
【解决】联想拯救者vmware启动虚拟机蓝屏重启问题
[solution] the blue screen restart problem of the virtual machine started by the VMware of Lenovo Savior
Cultivate children's creativity under the concept of project steam Education
Utonmos adheres to the principle of "collection and copyright" to help the high-quality development of traditional culture