In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use the HTML5 drag-and-drop function". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor learn how to use the HTML5 drag-and-drop function.
Drag and drop element
The HTML5 drag-and-drop feature allows users to drag and drop elements to another location. The placement location may be another application. When you drag an element, the mouse pointer follows the translucent representation of the element.
Let's try the following example to understand how it works:
Try this code for example »
Using Drag and Drop
Function dragStart (e) {
/ / Sets the operation allowed for a drag source
E.dataTransfer.effectAllowed = "move"
/ / Sets the value and type of the dragged data
E.dataTransfer.setData ("Text", e.target.getAttribute ("id"))
}
Function dragOver (e) {
/ / Prevent the browser default handling of the data
E.preventDefault ()
E.stopPropagation ()
}
Function drop (e) {
/ / Cancel this event for everyone else
E.stopPropagation ()
E.preventDefault ()
/ / Retrieve the dragged data by type
Var data = e.dataTransfer.getData ("Text")
/ / Append image to the drop box
E.target.appendChild (document.getElementById (data))
}
# dropBox {
Width: 300px
Height: 300px
Border: 5px dashed gray
Background: lightyellow
Text-align: center
Margin: 20px 0
Color: orange
}
# dropBox img {
Margin: 25px
}
Drag and Drop Demo
Drag and drop the image into the drop box:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.