<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Document</title>
<style type="text/css">
*{ margin:0;padding:0;}
div{
float:left;
width:200px;
height:200px;
margin-left:20px;
}
.div1{
border: 1px solid red;
}
.div2{
border: 1px solid blue;
}
p{
display:inline-block;
background:orange;
margin-top:20px;
}
</style>
</head>
<body>
<div class="div1" id="div1">
<p draggable="true" id="pe">把我拖拽过去</p>
<p draggable="true" id='pe1'>把我也拖拽过去</p>
</div>
<div class="div2" id="div2"></div>
<script>
/* 应用于拖拽元素的事件
ondrag 整个拖拽过程都会调用--持续
ondra
h5原生拖拽功能的实现
最新推荐文章于 2024-05-15 17:05:01 发布
本文详细探讨了HTML5的原生拖放功能,通过dataTransfer对象实现数据交换,覆盖ondragstart、ondragenter、ondragover、ondrop等关键事件,创建流畅的拖放体验。在Web应用中,这种功能常用于文件上传、元素布局等场景。
摘要由CSDN通过智能技术生成