Input Text focus() method

Definition and Usage

focus() The method is used to give focus to a text field.

Hint:Usage blur() method Focus can be removed from the text field.

Example

Set Focus on Text Field:

document.getElementById("myText").focus();

Try It Yourself

Syntax

textObject.focus()

Parameters

None.

Technical Details

Return Value:

No Return Value.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support