HTML DOM Marquee behavior Property
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;" > w3wiki </ h1 > < h2 >DOM Marquee behavior property</ h2 > < marquee id = "marqueeID" direction = "right" behavior = "slide" > w3wiki:A computer Science Portal for Beginner </ 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;" > w3wiki </ h1 > < h2 >DOM Marquee behavior Property</ h2 > < marquee id = "marqueeID" direction = "right" behavior = "slide" > w3wiki:A computer Science Portal for Beginner </ 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:
Contact Us