0% found this document useful (0 votes)
3 views2 pages

JavaScript Event Types Explained

The document provides a brief overview of various JavaScript events, including onclick, onsubmit, onfocus, onload, onchange, onkeyup, onmouseover, and onmouseout. Each event is described with its trigger condition and a simple example. These events are essential for handling user interactions and form validation in web applications.

Uploaded by

tanusneha456
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

JavaScript Event Types Explained

The document provides a brief overview of various JavaScript events, including onclick, onsubmit, onfocus, onload, onchange, onkeyup, onmouseover, and onmouseout. Each event is described with its trigger condition and a simple example. These events are essential for handling user interactions and form validation in web applications.

Uploaded by

tanusneha456
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

JavaScript Events - Short Answers

1. onclick Event
Triggered when a user clicks an element. Used for actions on click.

Example:
<button onclick="alert('Clicked!')">Click</button>

2. onsubmit Event
Occurs when a form is submitted. Used for form validation.

Example:
<form onsubmit="return validate()">

3. onfocus Event
Fires when an element (like input) gains focus.

Example:
<input onfocus="[Link]='yellow'">

4. onload Event
Fires when the page or image is fully loaded.

Example:
<body onload="init()">

5. onchange Event
Occurs when the value of an input or select changes.

Example:
<select onchange="alert('Changed!')">

6. onkeyup Event
Fires when a key is released. Useful for real-time input.

Example:
<input onkeyup="[Link]([Link])">

7. onmouseover Event
Fires when mouse is over an element.

Example:
<div onmouseover="[Link]='red'">Hover</div>
8. onmouseout Event
Fires when mouse leaves the element.

Example:
<div onmouseout="[Link]='black'">Leave</div>

You might also like