An HTML event can be something the browser does, or something a user does.
Here are some examples of HTML events:
Often, when events happen, you may want to do something.
JavaScript lets you execute code when events are detected.
Event | Description |
---|---|
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 |
Event handlers can be used to handle, and verify, user input, user actions, and browser actions:
Many different methods can be used to let JavaScript work with events:
A JavaScript can be executed when an event occurs, like when a user clicks on an HTML element.
Examples of HTML events:
element.addEventListener(event, function, useCapture);
Note that you don't use the "on" prefix for the event; use "click" instead of "onclick"
Event propagation is a way of defining the element order when an event occurs. If you have a <p> element inside a <div> element, and the user clicks on the <p> element, which element's "click" event should be handled first?
The removeEventListener() method removes event handlers that have been attached with the addEventListener() method:
element.removeEventListener("mousemove", myFunction);
https://learn.javascript.ru/event-details События в деталях
https://learn.javascript.ru/forms-controls Формы, элементы управления
Create simple ToDo list
When you click on the add button your confirm window is shown with the name of the ToDo item.
*Optonal task: add ability to delete the created ToDo items