HTML5 drag and drop instances, html5 drag

Source: Internet
Author: User

HTML5 drag and drop instances, html5 drag
Drag and Drop Related Properties

The draggable attribute is a global attribute of html5. It is one of the ways that html5 supports drag-and-drop operations. It is used to indicate whether an element can be dragged and dropped. draggable has three values. true indicates that the element can be dragged and dropped, false indicates that the browser cannot be dragged or dragged. auto indicates that the default value of the browser is used.

<Ul> <li id = "item1" draggable = "true"> List 1 </li> <li id = "item2" draggable = "true"> List 2 </li> <li id = "item3" draggable = "true"> List 3 </li> <li id = "item4" draggable = "true"> list 4 </li> <li id = "item5" draggable = "true"> List 5 </li> <li id = "item6" draggable = "true"> list 6 </li> </ul>
Drag related events

Ondragstart: This event triggers ondrag when the user starts to drag an element or selects text: triggers ondragend when the element is being dragged: triggers ondragleave when the user completes the drag-and-drop of an element: ondragover is triggered when the dragged object leaves the container range: this event is triggered when the dragged object is dragged within the container range of another object, this event occurs on the target element ondrop: triggered when the mouse is released during a drag process. This event acts on the target element.

DataTransfer object related methods

SetData (format, data): Add Custom data format getData (format): Get custom data format clearData ([format]): Clear Custom data format and data

Event. preventDefault ()

This method prevents the default action of an event. In ondragover, you must execute preventDefault (). Otherwise, the ondrop event will not be triggered.

Implementation case:

<! DOCTYPE html> 
Address: http://dadifeihong.com/html5tuo-zhuai/
Qr scanning: front-end applications-more practical cases

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.