Home > Web Front-end > JS Tutorial > body text

html drag drag event

韦小宝
Release: 2018-05-18 15:39:46
Original
3172 people have browsed it

In html, event processing is completed in js. HTML, js and css are inseparable. The following is an example of handling drag and drop events in js.

The drag event is divided into two parts, one is the processing of the drag target (i.e. the drag target); the other is the processing of the drag target (i.e. release target).

Trigger event on the drag target (source element):

ondragstart - Triggered when the user starts dragging the element

ondrag - triggered when the element is being dragged

ondragend - triggered after the user completes dragging the element

Events triggered when the target is released:

ondragenter - This event is triggered when the object being dragged by the mouse enters its container scope

ondragover - This event is triggered when a dragged object is dragged within the scope of another object's container

ondragleave - This event is triggered when the object being dragged by the mouse leaves the scope of its container

ondrop - This event is triggered when the mouse button is released during a dragging process

The implementation code is as follows: box1 and lists can be dragged to each other




    
    Title
    
    

  • 数据1
  • 数据2
  • 数据3
  • 数据4
  • 数据5
  • 数据6
Copy after login

##Among them: The getElementsByTagName() method returns a collection of objects with the specified tag name.

e.preventDefault(); is to prevent the system’s default drag event.

appendChild() is to add a control to the specified control.

e.preventDefault();
Copy after login
The above is all the content of html drag event, I hope it will be helpful to everyone.

Related recommendations:

Use JS and html to make a simple drawing board code

Js process of operating DOM objects

html js related issues

The above is the detailed content of html drag drag event. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!