<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
width: 100px;
height: 100px;
background: yellow;
-webkit-transition: 2s;
transition: 2s;
}
#myDIV:hover {
width: 400px;
}
</style>
</head>
<body>
<p>请将鼠标悬停在下方的 div 元素上,等待过渡效果结束。</p>
<p>propertyName 属性返回过渡效果所对应的 CSS 属性的名称。</p>
<div id="myDIV"></div>
<p><b>注释:</b>本例在 Internet Explorer 9 和更早版本中不起作用。</p>
<script>
document.getElementById("myDIV").addEventListener("webkitTransitionEnd", myFunction);
document.getElementById("myDIV").addEventListener("transitionend", myFunction);
function myFunction(event) {
this.innerHTML = "CSS Property used: " + event.propertyName;
}
</script>
</body>
</html>