31 - Events in JavaScript | Introduction to Events

Опубликовано: 19 Октябрь 2024
на канале: GoPHP
321
7

Events are actions or occurrences that happen in your Application. For example, if the user clicks a button on a webpage, you might want to respond to that action by displaying an information box.
There are a lot of different types of events that can occur, for example:
The user clicking the mouse over a certain element or hovering the cursor over a certain element.
The user pressing a key on the keyboard.
The user resizing or closing the browser window.
A web page finishing loading.
A form being submitted.
A video being played, or paused, or finishing play.
An error occurring.

Each available event has an event handler, which is a block of code (usually a JavaScript function that you as a programmer create) that will be run when the event fires.
Note that event handlers are sometimes called event listeners