Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input Text focus() method

Input Text focus() method

Input Text Object Reference The Input Text object

Example

Set the focus to a text field:

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

Try it »


Definition and Usage

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

Tip: Use blur() The method removes the focus from the text field.


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

All major browsers support the focus() method.


Syntax

textObject

.focus()

Parameters

None.

Technical details

Return Value: No return value

Input Text Object Reference The Input Text object