document.classes.backgroundColor

JavaScript 1.2+ Nav4+ Syntax

document.classes.className.tagName.backgroundColor

Description

The backgroundColor property specifies the background color associated with the class called className. The definition can also specify a tag ( tagName ) or the word all for tagName.

Example

Listing 7.61 uses the backgroundColor property to make the background color around an anchor red.

Listing 7.61 Setting the Background Color with the backgroundColor Property
<html>

<script>
<!-- Hide

//Create a style sheet class that contains the background color
document.classes.BG.all.backgroundColor = "red";

//Hide End --->
</script>

<b class=BG>This</b> is an anchor that uses
styles from the BG class.

</html>
							
						

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.