Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | DOM Style transitionDelay Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The transitionDelay property in HTML DOM is used to specify the time in seconds or milliseconds when execution of transition starts. The delay refers to the time, which to be waited before starting the transition effect. 

Syntax:

  • It returns the transitionDelay property.
object.style.transitionDelay
  • It sets the transitionDelay property.
object.style.transitionDelay = "time|initial|inherit"

Return Values: It returns a string value that represents the transition-delay property of an element

Property Values:

  • time: It specifies the length of time (in seconds or milliseconds) to start transition animation. 

Syntax:

object.style.transitionDelay = "time";
  • Example: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM Style transitionDelay Property
    </title>
     
    <!-- CSS property for transition animation -->
    <style>
        #GFG {
            border: 1px solid black;
            background-color: white;
            width: 250px;
            height: 200px;
            overflow: auto;
            -webkit-transition: all 3s;
            transition: all 3s;
            text-align:center;
        }
         
        #GFG:hover {
            background-color: green;
            width: 300px;
            height: 100px;
            
            text-align:center;
        }
    </style>
</head>
 
<body>
 
    <button onclick="myGeeks()">
        Click Here!
    </button>
     
    <br><br>
     
    <div id = "GFG">
        <h1>GeeksforGeeks</h1>
    </div>
     
    <!-- script for transition delay -->
    <script>
        function myGeeks() {
            document.getElementById("GFG").style.WebkitTransitionDelay
                    = "3s";
                     
            document.getElementById("GFG").style.transitionDelay
                    = "3s";    
        }
    </script>
</body>
 
</html>                   

  • Output: Before click on the Button:

  

After click on the Button: Transition delay : 3 seconds 

  • initial: It sets the transitionDelay property to its default value. 

Syntax:

object.style.transitionDelay = "initial";
  • Example: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM Style transitionDelay Property
    </title>
     
    <!-- CSS property for transition animation -->
    <style>
        #GFG {
            border: 1px solid black;
            background-color: white;
            width: 250px;
            height: 200px;
            overflow: auto;
            -webkit-transition: all 3s;
            transition: all 3s;
            text-align:center;
        }
         
        #GFG:hover {
            background-color: green;
            width: 300px;
            height: 100px;
            
            text-align:center;
        }
    </style>
</head>
 
<body>
 
    <button onclick="myGeeks()">
        Click Here!
    </button>
     
    <br><br>
     
    <div id = "GFG">
        <h1>GeeksforGeeks</h1>
    </div>
     
    <!-- script for transition delay -->
    <script>
        function myGeeks() {
            document.getElementById("GFG").style.WebkitTransitionDelay
                    = "initial";
                     
            document.getElementById("GFG").style.transitionDelay
                    = "initial";    
        }
    </script>
</body>
 
</html>                           

  • Output: Before click on the Button:

  

After click on the Button: Transition delay : 0 seconds. Because default transition delay is 0 seconds.

  • inherit: The transitionDelay property is inherited from its parent. 

Syntax:

object.style.transitionDelay = "inherit";
  • Example 3: 

html




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM Style transitionDelay Property
    </title>
     
    <!-- CSS property for transition animation -->
    <style>
        #GFG {
            border: 1px solid black;
            background-color: white;
            width: 250px;
            height: 200px;
            overflow: auto;
            -webkit-transition: all 3s;
            transition: all 3s;
            text-align:center;
        }
         
        #main {
            transition-delay:2s;
            -webkit-transition-delay:2s
        }
        #GFG:hover {
            background-color: green;
            width: 300px;
            height: 100px;
            
            text-align:center;
        }
    </style>
</head>
 
<body>
 
    <button onclick="myGeeks()">
        Click Here!
    </button>
     
    <br><br>
     
    <div id = "main">
        <div id = "GFG">
            <h1>GeeksforGeeks</h1>
        </div>
    </div>
     
    <!-- script for transition delay -->
    <script>
        function myGeeks() {
            document.getElementById("GFG").style.WebkitTransitionDelay
                    = "inherit";
                     
            document.getElementById("GFG").style.transitionDelay
                    = "inherit";    
        }
    </script>
</body>
 
</html>                   

  • Output: Before click on the Button:

  

After click on the Button: Transition delay : 2 seconds. Because the parent class contains transition delay 2 seconds.

Return Value: It returns a string value which represents the transitionDelay property of an element. 

Supported Browsers: The browser supported by DOM transitionDelay property are listed below:

  • Google Chrome 26.0 and above
  • Edge 12 and above
  • Internet Explorer 10.0 and above
  • Firefox 16.0 and above
  • Safari 9.0 and above
  • Opera 12.1 and above

My Personal Notes arrow_drop_up
Last Updated : 05 Jun, 2022
Like Article
Save Article
Similar Reads
Related Tutorials