Web Design

(Nancy Kaufman) #1

216


Change the Visibility of an Object (continued)


& In the body, type <a
href=”javascript:
void”.



  • Type onclick=
    ”hideDiv()”>.


( Type descriptive text for the
link.


) Type .


! Type function
showDiv().


@ Press.


Type { and press.


$ Type document.
getElementById(“?”).
style.visibility =
“visible”;, replacing?
with the ID you used in
Step 2.


% Press.


^ Type }.


Change the Visibility of an Object (continued)


I


f you encapsulate your JavaScript in a function, you must explicitly call the function in order for
it to run. JavaScript can be called via either browser events such as the page loading, or through

user events such as moving the mouse over something or clicking. HTML has a set of event attributes


available to match these actions. For example, if you want JavaScript to execute when the user clicks


a link, you can add the onclick attribute to the link. The attribute’s value will be set to the name


of the function you want to call.


(^1314)


20


11


16


17


18 19

Free download pdf