


The event ondragenter is triggered in H5 when the dragged element or selected text enters a valid drop target.
Example
Executed when the dragged element enters the drop targetJavaScript :
1 |
|
Definition and usage
ondragenter Event Triggered when the dragged element or selected text enters a valid drop target.
Ondragenter and ondragleave events can help users better understand the process of draggable elements entering and leaving the placement area. You can set different background colors when a draggable element enters and leaves the drop zone.
Drag and drop is a very common feature in HTML5. For more information, check out HTML5 Drag and Drop in our HTML tutorial.
Note: To make an element draggable, you need to use the HTML5 draggable attribute.
Tip: Links and images are draggable by default and do not require the draggable attribute.
The following events will be triggered during the drag and drop process:
Trigger events on the drag target (source element):
ondragstart - User Fires when you start dragging the element
ondrag - Fires when the element is being dragged
ondragend - Fires after the user completes dragging the element
Events triggered when the target is released:
ondragenter - This event is triggered when the object 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 container
ondragleave - When an object is dragged by the mouse This event is triggered when the object leaves the scope of its container
ondrop - This event is triggered when the mouse button is released during a drag process
Browser support
The number in the table indicates the version number of the first browser that supports this event.
Syntax
HTML:
1 |
|
JavaScript:
1 |
|
JavaScript, use the addEventListener() method :
1 |
|
Note: Internet Explorer 8 and earlier IE versions do not support the addEventListener() method.
Technical details
Whether bubbling is supported: | Yes |
Can be canceled : | Yes |
Event type: | DragEvent |
Supported HTML tags: | All HTML elements |
更多实例
实例
以下实例演示了所有的拖放事件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
The above is the detailed content of The event ondragenter is triggered in H5 when the dragged element or selected text enters a valid drop target.. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
