lt;!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>拖曳</title>
<style>
body {
padding: 0;
margin: 0;
background-color: #F7F7F7;
position: relative;
}
.box {
width: 150px;
height: 150px;
background-color: yellow;
position: absolute;
top: 100px;
left: 50px;
}
.container {
width: 300px;
height: 300px;
background-color: green;
position: absolute;
top: 100px;
left: 50%;
margin-left: -150px;
}
</style>
</head>
<body>
<div class="box" draggable="true"></div>
<div class="container"></div>
<script>
var box=document.querySelector('.box');
var container=document.querySelector('.container');
// 整個拖拽都會執行
box.addEventListener('drag', function () {
console.log(1);
});
box.addEventListener('dragleave', function () {
console.log(2);
});
// 拖拽開始
box.addEventListener('dragstart', function () {
this.style.backgroundColor='pink';
console.log(3)
});
// 拖拽結束
box.addEventListener('dragend', function (ev) {
this.style.backgroundColor='';
// console.log(ev);
});
// 進入到目標
container.addEventListener('dragenter', function () {
this.style.backgroundColor='pink';
});
// 在目標元素上移動
container.addEventListener('dragover', function (ev) {
this.style.backgroundColor='yellow';
ev.preventDefault();
});
//
container.addEventListener('drop', function (ev) {
this.style.backgroundColor='black';
console.log(ev);
ev.preventDefault();
});
</script>
</body>
</html>
1),截圖
(2),文件夾, 線條, 頁面等圖標暫不能提供, 暫截圖
(3),代碼
orm表單復雜demo制作與涉及到的方法講解,深入理解form基本屬性與使用方法
*請認真填寫需求信息,我們會在24小時內與您取得聯系。