JavaScript DOM HTML method: addEventListener()
[this page | pdf | back links]
The addEventListener() method (when
applied to HTML
elements in the JavaScript
DOM) attaches
an event handler to the element.
It
has the following syntax with the following parameters. It does not return
any value.
element.addEventListener(event, function, useCapture)
|
Parameter
|
Required / Optional
|
Description
|
|
event
|
Required
|
String specifying event
(excluding the ‘on’ part at
the start of the relevant event attribute name)
|
|
function
|
Required
|
Name of function (with
‘()’ included at end)
|
|
useCapture
|
Optional
|
If true then event handler is executed
in the capturing phase of the page load, if false then in the bubbling phase
|
Some earlier versions of
some major browsers do not support this method. For these browsers you instead
need to use the attachEvent()
method.
NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)