/

HTML / CSS / JavaScript Tutorial

HTML Event attribute: ondragstart

[this page | pdf | back links]

The HTML ondragstart attribute specifies the event that is triggered at the start of a drag. It applies to all visible elements.

 

EXAMPLE:


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

<script>
function myOndragstart() {alert("Starting to drag element");}
</script>

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes


Desktop view | Switch to Mobile