JavaScript can be used to control the display of elements on a web page. E.g., suppose I don't wish visitors to a webpage to see a certain element on the page unless the width of their browser window is a specified value. The element could be a div, which might contain an advertisement or some other image that might be too wide for a browser window that was less than a certain width. So I want to hide the display of the element, so that it doesn't detract from the aesthetics of the page.
I could put the following code in the HEAD section of the webpage, if
I wanted any DIV element on the page that has a class of
sometimesHide
to be hidden in certain circumstances. The
styling I chose below is arbitrary, you could use would ever you preferred
and you could put the style information in an external
Cascading Style Sheets (CSS) file, instead.
<style type="text/css"> .sometimesHide { background-color: MediumOrchid; color: white; margin: 25px;} </style>
[ More Info ]