First, touch me (put your mouse over this text).
Finally, touch me and watch what happens.
Then move your mouse toward the bottom of the screen, and watch what happens to all three paragraphs.
All of these changes happen because we change styles as a result of mouse events.
In a stylesheet, we set up three classes, as follows:
Next, we invoke a style based on a mouse event. The code is
The code above allows you to assign a new class to the paragraph when the mouse moves over or moves away from that paragraph. However, you also can cause the style on one paragraph to change when the user moves the mouse over a different paragraph. That requires some explicit JavaScript coding, with a program called setClass
The setClass function needs to be put onto your page of JavaScript code that is linked to from your HTML page.
To use this function, you need to assign an ID to a block of text on the HTML page. For example, you could have:
We can have a mouse event on another paragraph change the look of the "block1" paragraph as follows: