Six JavaScript Events

Ondrop Event

The ondrop event occurs when a draggable element is dropped onto a valid drop target. It is commonly used to handle drag-and-drop interactions in a webpage.

Please, drag the emoji from A to B

A

😀

B


Onended Event

The onended event triggers when a media element (like audio or video) has finished playing. It is useful for performing actions after playback, such as showing a message or starting another video.

This is my friend singing! Press play and wait for it to end.


Onmousedown Event

The onmousedown event fires when a mouse button is pressed down over an element. It is often used to initiate drag operations or create interactive buttons.

Click this text!


Onpaste Event

The onpaste event occurs when the user pastes content from the clipboard into an input field or editable area. It can be used to validate or modify pasted data.


Onselect Event

The onselect event triggers when the user selects text in an input field or textarea. It is useful for tracking or reacting to text selection.

Select the text:


Onsubmit Event

The onsubmit event occurs when a form is submitted. It is often used to validate form data before sending it to a server or to prevent submission for certain conditions.

Enter name: