Home >Web Front-end >JS Tutorial >Implementation ideas for div losing focus event_javascript skills
To read this article, you must first understand the following events (excerpted from w3c).
blur event: The blur event occurs when an element loses focus.
focus event: The focus() method is used to give focus to the text field (it also allows certain elements to get focus events).
tabIndex attribute: The tabIndex attribute can set or return the tab key control order of the button.
We all know that blur is only for form controls, but for span, div, li and the like, there is no way to trigger their actions. Now we only need to set a tabindex attribute to trigger their focus. event.
Real project code: