Skip to content
Related Articles

Related Articles

HTML DOM Marquee loop Property

Improve Article
Save Article
Like Article
  • Last Updated : 21 Feb, 2022

The Marquee loop property in HTML DOM is used to set or return the value of the loop attribute of the <marquee> element.  The loop attribute is used to specify the number of times the marquee text should loop. 

Syntax:

  • It returns the marquee loop property.

    marqueeObject.loop; 
  • It sets the marquee loop property.

    marqueeObject.loop ="number";

Property Values: It contains a numeric value that represents the number of times that the marquee should loop. The default value of the loop is INFINITE.

Example 1:  Below HTML code returns the marquee loop property. 

HTML




<!DOCTYPE html>
<html>
          
    <body style="text-align:center;">
      
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
          
        <h2>DOM Marquee loop property</h2>
          
        <marquee id="marqueeID" direction="right" 
                 behavior="slide" loop="3">
            GeeksforGeeks:A Computer Science Portal for Geeks
        </marquee>        
        <br><br>
          
        <button onclick="btnClick()">
          Return loop property
        </button>
         <p id ="paraID"></p>
  
        <script>
            function btnClick() {
                var txt = document.getElementById("marqueeID").loop;
                document.getElementById("paraID").innerHTML = txt;
            }
        </script>    
    </body>
</html>

Output:

HTML DOM Marquee loop Property

HTML DOM Marquee loop Property

Example 2: Below HTML code sets the marquee loop property. 

HTML




<!DOCTYPE html>
<html>
          
    <body style="text-align:center;">
      
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
          
        <h2>DOM Marquee loop property</h2>
          
        <marquee id="marqueeID" direction="right" 
                 behavior="slide" loop="3">
            GeeksforGeeks:A computer Science Portal for Geeks
        </marquee>        
        <br><br>
          
        <button onclick="btnClick()">
          Set loop property
        </button>
        <p id ="paraID"></p>
  
        <script>
            function btnClick() {
                var txt = document.getElementById(
                    "marqueeID").loop = "5";
  
                document.getElementById("paraID").innerHTML
                    = "The value of the loop attribute"
                    + " was changed to " + txt;
            }
        </script>    
    </body>
</html>

Output:

HTML DOM Marquee loop Property

HTML DOM Marquee loop Property


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!