HTML DOM Marquee bgColor Property
The HTML DOM Marquee bgColor property is used to set or return the value of the bgcolor attribute of the <marquee> tag.
Syntax
It returns the marquee bgColor property.
marqueeObject.bgColor;
It sets the marquee bgColor Property.
marqueeObject.bgColor="colorname/hex_number"
Property values
- color_name: It sets the background color by using the color name. For example “red”.
hex_number: It sets the background color by using the color hex code. For example “#0000ff”.
Note: The HTML Marquee bgcolor attribute is not supported by HTML5.
Example 1: Below HTML code returns the Marquee bgcolor property.
<!DOCTYPE html>
<html>
<head>
<title>
DOM Marquee bgColor Property
</title>
</head>
<body style="text-align:center;">
<h2>DOM Marquee bgColor Property</h2>
<marquee id="marqueeID" direction="right"
behavior="slide" loop="3" bgcolor="green">
w3wiki: A computer Science Portal for Beginner
</marquee>
<br><br>
<button onclick="btnClick()">
Return background color of Marquee tag
</button>
<p id="paraID"></p>
<script>
function btnClick() {
let txt = document.getElementById("marqueeID").bgColor;
document.getElementById("paraID").innerHTML = txt;
}
</script>
</body>
</html>
Output
Example 2: Below HTML code sets the Marquee bgColor property.
<!DOCTYPE html>
<html>
<head>
<title>
DOM Marquee bgColor Property
</title>
</head>
<body style="text-align:center;">
<h2>DOM Marquee bgColor Property</h2>
<marquee id="marqueeID" direction="right"
behavior="slide" loop="3" bgcolor="green">
w3wiki: A computer Science Portal for Beginner
</marquee>
<br><br>
<button onclick="btnClick()">
Change Background Color of Marquee Tag
</button>
<p id="paraID"></p>
<script>
function btnClick() {
let txt = document.getElementById("marqueeID")
.bgColor = "dodgerblue";
document.getElementById("paraID").innerHTML = txt;
}
</script>
</body>
</html>
Output
Supported Browsers
- Chrome 1
- Edge 12
- Firefox 65
- Opera 7.2
- Safari 1.2