HTML | ondragenter Event Attribute
The ondragenter event attribute in HTML works when the content is draggable. An element is made by setting the draggable attribute value to true. The draggable attribute can take only true or false value.
Syntax:
<element ondragenter = "script">
Attribute Value: This attribute contains single value script which works when ondragenter event attribute called.
Example 1:
<!DOCTYPE html> <html> <head> <title> HTML ondragenter Event Attribute </title> <!-- script to add background color --> <script> function MyFunction() { document.getElementById("geeks").style.backgroundColor = "green"; } </script> </head> <body id = "geeks" style = "text-align:center"> <!-- ondragenter event call here --> <h1 ondragenter = "MyFunction()" draggable = "true"> GeeksforGeeks </h1> <p>Drag heading content to change background color</p> </body> </html> |
Output:
Before dragging the content:

After dragging the content:

Example 2:
<!DOCTYPE html> <html> <head> <title> HTML ondragenter Event Attribute </title> <script> function dragenter_time() { document.getElementById("geeks").innerHTML = "The date and time is: " + Date(); } </script> </head> <body> <center> <!-- ondragenter event call here --> <p id = "geeks" ondragenter="dragenter_time()" draggable = "true">Drag to know time </p> </center> </body> </html> |
Output:
Before dragging the content:

After dragging the content:

Supported Browsers: The browser supported by ondragenter event attribute are listed below:
- google Chrome 4.0
- Internet Explorer 9.0
- Firefox 3.5
- Safari 6.0
- Opera 12.0
Recommended Posts:
- HTML | DOM ondragenter Event
- HTML | onsubmit Event Attribute
- HTML | onresize Event Attribute
- HTML | onmouseover Event Attribute
- HTML | oncontextmenu Event Attribute
- HTML | onkeydown Event Attribute
- HTML | ondragover Event Attribute
- HTML | onpaste Event Attribute
- HTML | onoffline Event Attribute
- HTML | onfocus Event Attribute
- HTML | onselect Event Attribute
- HTML | ondragend Event Attribute
- HTML | ondragleave Event Attribute
- HTML | ononline Event Attribute
- HTML | onclick Event Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



