Open In App

HTML | DOM Style transitionDelay Property

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:



object.style.transitionDelay
object.style.transitionDelay = "time|initial|inherit"

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

Property Values:



Syntax:

object.style.transitionDelay = "time";




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

  

After click on the Button: Transition delay : 3 seconds 

Syntax:

object.style.transitionDelay = "initial";




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

  

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

Syntax:

object.style.transitionDelay = "inherit";




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

  

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:


Article Tags :