What is the difference between focus and blur events
This is part of the
Semicolon&Sons Code Diary
- consisting of lessons learned on the job. You're in the
javascript category.
Last Updated: 2024-11-23
Focus event
- occurs when you click on or tab to an element
- related to the
autofocus
attribute, which puts the focus on an element as soon as the user lands on the page
Blur event
- occurs when a field loses focus. E.g. if you click an input then move away. Can be used, for example, to trigger validations.