/

HTML / CSS / JavaScript Tutorial

HTML Event attribute: ondragleave

[this page | pdf | back links]

The HTML ondragleave attribute specifies the event that is triggered when an element is dragged outside a valid drop target. It applies to all visible elements.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
ondragenter, ondragleave: try dragging the yellow <span style="background-color: yellow;">element</span>
onto and off of the orange
<span style="background-color: orange;" ondragenter="myOndragenter()" ondragleave="myOndragleave()">element</span>
<br><br><b id="enterleave"></b><br>

<script>
function myOndragenter() {document.getElementById("enterleave").textContent="Entered";}
function myOndragleave() {document.getElementById("enterleave").textContent="Left";}
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile