Select.focus()

JavaScript1.0+, JScript1.0+ Nav2+, IE3+, Opera3+ Syntax

							select.focus()

Description

The focus() method of the Select object gives the focus to the select box. Be careful when using this method in conjunction with the Select.blur() method. It can lead to a focus/blur loop, where the browser blurs a focus as soon as it is done, and vice versa.

Example

Listing 7.465 has two text boxes and two buttons. If the user clicks the first button, the cursor is set inside the first text box. If the user clicks the second text box, the cursor is set inside the second text box.

Listing 7.465 Using the focus() Method to Place the Cursor in the Desired Select Box
 <html> <head> <script language="JavaScript"> <!-- Hide // Define the setFocus ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.