Wait 2 seconds before the transition effect starts:
document.getElementById("myDIV").style.transitionDelay = "2s";
Click the button and mouse over the DIV element again.
The changes will now wait 2 seconds before happening:
<!DOCTYPE html> <html> <head> <style> #myDIV {//from w w w . j a v a 2s. c om border: 1px solid black; background-color: lightblue; width: 270px; height: 200px; overflow: auto; transition: all 2s; } #myDIV:hover { background-color: coral; width: 570px; height: 500px; padding: 100px; border-radius: 50px; } </style> </head> <body> <p>Mouse over the DIV element and it will change, both in color and size!</p> <button onclick="myFunction()">Test</button> <div id="myDIV"> <h1>myDIV</h1> </div> <script> function myFunction() { document.getElementById("myDIV").style.transitionDelay = "2s"; } </script> </body> </html>
The transitionDelay property specifies when the transition effect will start.
The transitionDelay value is defined in seconds (s) or milliseconds (ms).
Property Values
Value | Description |
---|---|
time | Sets the number of seconds or milliseconds to wait before the transition effect will start |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
The transitionDelay property Default Value: 0
The transitionDelay property returns a String representing the transition-delay property of an element.