HTML | DOM transitionend Event

The transitionend event in HTML DOM occurs when a CSS transition has ended. if the user removes transition before completion the event will not fire.

Syntax:

  • Code for Safari 3.1 to 6.0:
    object.addEventListener("webkitTransitionEnd", Script);
  • Standard syntax:
    object.addEventListener("transitionend", Script);

Example:



filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>HTML DOM transitionend Event</title>
    <style>
        #divID {
            width: 150px;
            height: 150px;
            background: green;
            -webkit-transition: height 1s;
            transition: height 1s;
        }
          
        #divID:hover {
            height: 300px;
        }
    </style>
</head>
  
<body>
  
    <center>
        <h1 style="color:green">GeeksforGeeks</h1>
        <h2>HTML DOM transitionend Event</h2>
        <div id="divID"></div>
    </center>
    <script>
        // Code for Safari 3.1 to 6.0
        document.getElementById(
          "divID").addEventListener("webkitTransitionEnd", GFGfun);
  
        // Standard syntax
        document.getElementById(
          "divID").addEventListener("transitionend", GFGfun);
  
        function GFGfun() {
            this.innerHTML = 
              "transitionend event occured - The transition has completed";
            this.style.backgroundColor = "limegreen";
        }
    </script>
  
</body>
  
</html>

chevron_right


Output:
Before:

After:

Supported Browsers: The browsers supported by DOM transitionend Event are listed below:

  • Google Chrome 26.0/4.0 (webkitTransitionEnd)
  • Internet Explorer 10.0
  • Firefox 16.0/4.0 (mozTransitionEnd)
  • Apple Safari 6.1/3.1 (webkitTransitionEnd)
  • Opera 12.1/10.5 (oTransitionEnd)


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : shubham_singh



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.