This repository was archived by the owner on Jun 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
$.on()
Arthur Guiot edited this page Jul 20, 2017
·
2 revisions
The $.on() function is super useful 👌 when you're dealing with events. When you want to execute a command when you click on a button, when you hover an element, etc...
Here are the most used JavaScript events, which you'll be able to use with the $.on() function.
| Events | Description |
|---|---|
| change | An HTML element has been changed |
| click | The user clicks an HTML element |
| mouseover | The user moves the mouse over an HTML element |
| mouseout | The user moves the mouse away from an HTML element |
| keydown | The user pushes a keyboard key |
| load | The browser has finished loading the page |
Here is a complete documentation of every event that you can use with the $.on() function 😊.
The $.on() function needs 3 arguments, which are:
- the element
- the event
- and the callback function
These 3 arguments are required to make this function work.
Let's have a look at an example. Here, we'll display an alert when a user clicks on a button:
HTML:
<button>Do not click on me!</button>JS:
$.on($.select("button"), "click", function () {
alert("🚨 You clicked on me!");
})Don't hesitate to ask your questions
- Home
- The Core Languages
- Getting Started: Installation
- The Basics (
$.var()+$.target()) - Developing for DisplayJS
-
$.select()- Text related
- If...else
$.xss()$.repeat()$.custom()$.live()$.load()$.on()$.onEvent()$.ready()- Scroll API
$.all()$.clone()$.is()$.valEmpty()$.remove()$.show()&$.hide()$.ajax()- Class Related
$.css()$.getStyle()- Fade effects
$.extend()$.dynamic()$.parent()- Elements-Nodes
$.component()$.time_ago()$.copy()$.then()$.sleep()$.getProp()