AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

JavaScript Events


JavaScript Tutorial » JavaScript Events

An event is something that happens when user interact with the web page, such as when he clicked a link or button, entered text into an input box or textarea, made selection in a select box, pressed key on the keyboard, moved the mouse pointer, submits a form, etc

An event handler for the click event is called onclick,
similarly an event handler for the load event is called onload,
event handler for the blur event is called onblur, and so on.

Assign a click handler for a button element, we can use onclick attribute, like this

Example:
<script>
<button type="button" onclick="alert('How are you')">Click Me</button>
</script>


Mouse Events - example


A mouse event is triggered when the user click some element, move the mouse pointer over an element, etc

The Click Event (onclick)

Click event occurs when a user clicks on an element on a web page.

Example:

<script>
<button type="button" onclick="alert('You have clicked
a button!');">Click Me</button>
<a href="#" onclick="alert('You have clicked a link!');">Click Me</a>

</script>



Contextmenu Event (oncontextmenu) - example


The Boolean data type can hold only two values: true or false.

Used to store values like yes (true) or no (false), on (true) or off (false).

Example:

<script>
<button type="button" oncontextmenu="alert('You have right-clicked
a button!');">Right Click on Me</button>
<a href="#" oncontextmenu="alert('You have right-clicked a link!');">Right Click on Me</a>
</script>

 

Common HTML Events, example

Common HTML Events
Here is a list of some common HTML events:

onchange An HTML element has been changed
onclick The user clicks an HTML element
onmouseover The user moves the mouse over an HTML element
onmouseout The user moves the mouse away from an HTML element
onkeydown The user pushes a keyboard key
onload The browser has finished loading the page



JavaScript Events list, listener, input, on. mouse, focus, select, in html, blur, mdn
JavaScript Events - javascript tutorial

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


0
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.