Web Design with HTML and CSS

(National Geographic (Little) Kids) #1
Interactivity on the web

Lesson 10, Introduction to Interactivity 219

Events are often based on user interaction, such as moving the mouse cursor over an object.

The onmouseout event is closely related to onmouseover and triggers the JavaScript when
the cursor leaves the area of the button.

Currently, this event is tied to your button, but you can move the event from the button
to the actual page.

3 Select the onmouseover event and its value, and then press Ctrl + X (PC) or
Command + X (Mac OS) to cut the code. Locate the opening body tag and press
Ctrl + V (PC) or Command + V (Mac OS) to paste the code as shown here:



A mouseover event on the actual page will work, but but best practices is to use the
onload event, which triggers your JavaScript as soon as the page is opened:
Free download pdf