JavaScript Events
« PreviousNext Chapter »
HTML events are "things" that happen to HTML elements.
When JavaScript is used in HTML pages, JavaScript can "react" on these events.
HTML Events
An HTML event can be something the browser does, or something a user does.
Here are some examples of HTML events:
An HTML web page has finished loading
An HTML input field was changed
An HTML button was clicked
Often, when events happen, you may want to do something.
JavaScript lets you execute code when events are detected.
HTML allows event handler attributes, with JavaScript code, to be added to HTML elements.
With single quotes:
With double quotes:
In the following example, an onclick attribute (with code), is added to a button element:
Example
The time is?
JavaScript Events« PreviousNext Chapter »HTML events are "things" that happen to HTML elements.When JavaScript is used in HTML pages, JavaScript can "react" on these events.HTML EventsAn HTML event can be something the browser does, or something a user does.Here are some examples of HTML events:An HTML web page has finished loadingAn HTML input field was changedAn HTML button was clickedOften, when events happen, you may want to do something.JavaScript lets you execute code when events are detected.HTML allows event handler attributes, with JavaScript code, to be added to HTML elements.With single quotes:With double quotes:In the following example, an onclick attribute (with code), is added to a button element:ExampleThe time is?
การแปล กรุณารอสักครู่..
