The HTML DOM Style transitionDelay property returns and modify when the transition effect of an element will begin.
Syntax
Following is the syntax −
1. Returning transitionDelay
object.transitionDelay
2. Modifying transitionDelay
object.transitionDelay = “value”
Here, value can be −
Sr.No | Value & Explanation |
---|---|
1 | initial It set this property value to its default value. |
2 | inherit It inherits this property value from its parent element. |
3 | time It represents the delay of a transition effect in seconds(s) or milliseconds(ms). |
Let us see an example of HTML DOM Style transitionDelay Property −
Example
<!DOCTYPE html> <html> <style> body { color: #000; height: 100vh; } .btn { background: #db133a; border: none; height: 2rem; border-radius: 2px; width: 40%; display: block; color: #fff; outline: none; cursor: pointer; margin: 1rem 0; } .circle { height: 100px; width: 100px; background-color: #db133a; } .circle:hover { height: 200px; width: 200px; border-radius: 50%; transition: all 1s; } .show { font-size: 1.2rem; margin: 1rem 0; } </style> <body> <h1>DOM Style transitionDelay Property Demo</h1> <div class='circle'></div> <button onclick="set()" class="btn">Set TransitionDelay</button> <div class="show">Now, hover on the square</div> <script> function set() { document.querySelector('.circle').style.transitionDelay = "2s"; } </script> </body> </html>
Output
Click on “Set TransitionDelay” button and then hover on the “red” square to see the transitionDelay effect.