Button.onFocus

JavaScript 1.1+, JScript 1.0+ Nav3+, IE 3+ Syntax

onFocus="command"

Description

The onFocus event handler is defined in an <input> tag and specifies what to do when the button gains focus.

Example

The code in Listing 7.30 uses the onFocus event handler to display an alert box any time the button gains focus.

Listing 7.30 Use onFocus Event Handler to Display an Alert Box When the Button Gains Focus
<html>
<form name="myForm">
  <input type="button"
         value="Big Button"
         name="myButton"
         onFocus="alert('Focus event occured')">
</form>

</html>
							
						

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.