Open In App

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:

Example 1:  Below HTML code returns the behavior property of <marquee> tag. 




<!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. 




<!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:


Article Tags :