# focus and blur methods in JavaScript

You already know what input focus is. You also know how to set or lose focus: to set, you need to click in the input field, and to lose - to some other place.

In JavaScript, however, there are special methods that allow you to force the focus to be on or off the input. These are the `focus` and `blur` methods.

Let's see how they work with an example. Let's say we have an input and a button:

`<input id="elem" value="text"> <input type="submit" id="button">`

Let's set the input focus to our input by clicking on the button:

`let elem = document.querySelector('#elem'); let button = document.querySelector('#button'); button.addEventListener('click', function() { elem.focus(); });`

Two inputs are given. Make it so that after entering two characters, the input focus goes to the second input, and after entering two characters into this input, the focus is removed from it.

←→
↑
en ru