/

HTML / CSS / JavaScript Tutorial

HTML Event attribute: ondrag

[this page | pdf | back links]

The HTML ondrag attribute specifies the event that is triggered when an element is dragged. It applies to all visible elements.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
ondrag: try dragging this
<span style="background-color: yellow;" ondrag="myOndrag()" ondragstart="myOndragstart()">element</span><br>

<script>
function myOndrag() {alert("Dragging element");}
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile