当前位置:网站首页>Div drag effect
Div drag effect
2022-07-25 22:14:00 【Grace God】
Copy the code implementation
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
body{
width: 700px;
height: 500px;
border: 1px solid #ccc;
display: flex;
margin: auto;
}
div{
width: 150px;
height: 150px;
color: honeydew;
text-align: center;
margin: auto;
}
</style>
<body>
<div style="background: rebeccapurple;" draggable="true">
<p> first </p>
<p> I was the first div</p>
</div>
<div style="background: red;" draggable="true">
<p> the second </p>
<p> I'm the second div</p>
</div>
<div style="background: gold;" draggable="true">
<p> Third </p>
<p> I'm the third div</p>
</div>
<div style="background: rgb(170, 2, 66);" draggable="true">
<p> The fourth one </p>
<p> I'm the fourth div</p>
</div>
</body>
<script>
let div= document.getElementsByTagName("div")
let container = null
for(let i=0;i<div.length;i++){
// Drag the
div[i].ondragstart = function(){
container = this
}
// place
div[i].ondragover=function(){
event.preventDefault()
}
// Replace
div[i].ondrop=function(){
if(container!=null && container!=this){
let temp = document.createElement("div")
document.body.replaceChild(temp,this)
document.body.replaceChild(this,container)
document.body.replaceChild(container,temp)
}
}
}
</script>
</html>边栏推荐
- Based on if nesting and function call
- Call of addition, subtraction, multiplication and division of integer type only
- Recursive case -c
- C language left value and right value description [easy to understand]
- All you want to know about interface testing is here
- 3. Editors (vim)
- D3.js 学习
- 还不懂mock测试?一篇文章带你熟悉mock
- The file cannot be saved (what if the folder is damaged and cannot be read)
- C language: random generated number + bubble sort
猜你喜欢

How to implement an app application to limit users' time use?

如何将一个域名解析到多个IP地址?

Randomly generate 10 (range 1~100) integers, save them to the array, and print the array in reverse order. And find the average value, the maximum value and the subscript of the maximum value, and fin

Tfrecord write and read

Visitor mode

Having met a tester with three years' experience in Tencent, I saw the real test ceiling

6-18漏洞利用-后门连接

Playwright tutorial (I) suitable for Xiaobai

6-18 vulnerability exploitation - backdoor connection

『SignalR』. Net using signalr for real-time communication
随机推荐
Wechat applet application development competition works comprehensive development record - Jinlu cultural tourism (cloud development - Overview)
Unity performance optimization direction
Internship: writing common tool classes
The second short contact of gamecloud 1608
字节跳动技术面都过了,结果还是被刷了,问HR原因竟是。。。
kubernetes之VictoriaMetrics单节点
D3.js learning
D3.js 学习
在腾讯干软件测试3年,7月无情被辞,想给划水的兄弟提个醒...
SQL basic statement DQL select and extract DML insert delete
jenkins+SVN配置
别投了,软件测试岗位饱和了...
Which is reliable between qiniu business school and WeiMiao business school? Is it safe to open an account recommended by the teacher?
Victoriametrics single node of kubernetes
[test development methodology] experience of test development platform PK - choice
『Skywalking』. Net core fast access distributed link tracking platform
面了个腾讯三年经验的测试员,让我见识到了真正的测试天花板
QML module not found
访问者模式(visitor)模式
Based on if nesting and function call