JavaScript Resources
Multiple Statements in Event Handlers
Events
- Events
- Event Handlers
- Single & Double Quotes
- Case Sensitivity
- Multiple Statements
- 12 Basic Event Handlers
You are not limited to just one executable statement as the value of an event handler. You can excecute additional statements by separating them with semicolons ;.
For example:
<img src="smiley.gif" onClick="var user = prompt('Who are you?');alert('Hi ' + user + '!');document.bgColor='red'" />
The final statement does not need to be followed by a semicolon, but there is no penalty for doing so.
Next up ... the 12 basic event handlers