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 value: I
-
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.
HTML
<!DOCTYPE html> < html >
< body style = "text-align:center;" >
< h1 style = "color:green;" >
GeeksforGeeks
</ h1 >
< h2 >DOM Marquee bgColor Property</ h2 >
< marquee id = "marqueeID" direction = "right"
behavior = "slide" loop = "3" bgcolor = "green" >
GeeksforGeeks:A computer Science Portal for Geeks
</ marquee >
< br >< br >
< button onclick = "btnClick()" >
Return background color of Marquee tag
</ button >
< p id = "paraID" ></ p >
< script >
function btnClick() {
var txt = document.getElementById("marqueeID").bgColor;
document.getElementById("paraID").innerHTML = txt;
}
</ script >
</ body >
</ html >
|
Output:
Example 2: Below HTML code sets the Marquee bgColor property.
HTML
<!DOCTYPE html> < html >
< body style = "text-align:center;" >
< h1 style = "color:green;" >
GeeksforGeeks
</ h1 >
< h2 >DOM Marquee bgColor Property</ h2 >
< marquee id = "marqueeID" direction = "right"
behavior = "slide" loop = "3" bgcolor = "green" >
GeeksforGeeks:A computer Science Portal for Geeks
</ marquee >
< br >< br >
< button onclick = "btnClick()" >
Change background color of Marquee tag
</ button >
< p id = "paraID" ></ p >
< script >
function btnClick() {
var txt = document.getElementById(
"marqueeID").bgColor = "dodgerblue";
document.getElementById("paraID").innerHTML = txt;
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers :
- Google Chrome 1.0
- Edge 12.0
- Firefox 65.0
- Internet Explorer 2.0
- Opera 7.2
- Safari 1.2