HTML and CSS Reference
In-Depth Information
EXPLANATION ( CONTINUED )
6
A second event listener registers another event, mouseover , to the second para-
graph. Now if the user clicks the mouse on the second paragraph or rolls the
mouse over, two events will be fired and their respective functions called, one to
highlight the text and the other to make the font larger.
7
The function highLight is called when the mouseover event is triggered on the first
paragraph. This function is nested within the anonymous function defined on line
1 that was called when the onload event was triggered on line 1.
8
The function has access to the object through the this keyword. (A function de-
fined within another function is called a closure. See Chapter 7, “Functions.”
9
This is the first paragraph that will be changed when the mouseover event is triggered.
10
This is the paragraph for which two events are registered, both the click and the
mouseover events, and demonstrates that more than one event can be registered
for the same object. This process is shown in Figures 15.40, 15.41, and 15.42.
Figure 15.40 Before an event occurs.
Figure 15.41 After clicking on both of the paragraphs.
Search WWH ::




Custom Search