HTML DOM Marquee behavior Property
Last Updated :
15 Jul, 2022
The HTML DOM Marquee behavior property is used to set or return the value of the behavior attribute of the <marquee> element. This attribute is used to set the behavior of the moving text across the <marquee> tag.
Syntax:
It is used to return the marquee behavior property.
marqueeobject.behavior;
It sets the marquee behavior property.
marqueeObject.behavior = "alternate|scroll|slide"
Note: This property is depreciated from HTML 5.
Property values:
- alternate: It defines that text moving to the end and then starting in the opposite direction.
- scroll: It has a default value. specify the text scrolls to the end and starts over.
- slide: It specifies the text moving to the end and then stops it.
Example 1: Below HTML code returns the behavior property of <marquee> tag.
HTML
<!DOCTYPE html>
< html >
< body style = "text-align:center;" >
< h1 style = "color:green;" >
GeeksforGeeks
</ h1 >
< h2 >DOM Marquee behavior property</ h2 >
< marquee id = "marqueeID" direction = "right" behavior = "slide" >
GeeksforGeeks:A computer Science Portal for Geeks
</ marquee >
< br >< br >
< button onclick = "btnClick()" >
Return Behavior property
</ button >
< p id = "paraID" ></ p >
< script >
function btnClick() {
var txt = document.getElementById("marqueeID").behavior;
document.getElementById("paraID").innerHTML = txt;
}
</ script >
</ body >
</ html >
|
Output:
Example 2: Below HTML code changes the behavior property of the marquee element.
HTML
<!DOCTYPE html>
< html >
< body style = "text-align:center;" >
< h1 style = "color:green;" >
GeeksforGeeks
</ h1 >
< h2 >DOM Marquee behavior Property</ h2 >
< marquee id = "marqueeID" direction = "right" behavior = "slide" >
GeeksforGeeks:A computer Science Portal for Geeks
</ marquee >
< br >< br >
< button onclick = "btnClick()" >
Set Behavior property
</ button >
< p id = "paraID" ></ p >
< script >
function btnClick() {
var txt = document.getElementById(
"marqueeID").behavior = "scroll";
document.getElementById("paraID").innerHTML = txt;
}
</ script >
</ body >
</ html >
|
Output:
Share your thoughts in the comments
Please Login to comment...