Advertisement
Home Open Editor ❯

HTML ondrag Attribute

Example

<p draggable="true" ondrag="myFunction(event)">Drag me!</p>

Meaning

The ondrag attribute specifies the script to be run when an element is dragged.

Note: To make an element draggable, use the global HTML5 draggable attribute.

Tip: A links and images are draggable by default there is no need of draggable attribute.


Standard Syntax

<element ondrag="script">


Applies to:

The ondrag attribute can be used on the following element:

Element Attribute
All visible elements. ondrag

Advertisement

Attribute Values

Value Description
script Specifies the script to be run on ondrag
Home Open Editor ❯
Advertisement