尽管使用了正确的前缀,但不会触发transitionend事件。
JS
var flyingCarElem = document.getElementById("flyingCar");
// register an event handler
// ('transitionEnd' for FireFox, 'webkitTransitionEnd' for webkit)
flyingCarElem.addEventListener("transitionEnd",function(){
// will be called when the transition has finished.
alert("The car arrived");
});
CSS
div {
width: 100px;
height: 100px;
background: red;
-webkit-transition: width 2s; /* Safari */
transition: width 2s;
}
div:hover {
width: 300px;
}
有人可以帮忙吗?
答案 0 :(得分:1)
Firefox中的转换结束事件称为
transitionend
而不是
transitionEnd
你的修复应该很容易:
var flyingCarElem = document.getElementById("flyingCar");
// register an event handler
// ('transitionend' for FireFox, 'webkitTransitionEnd' for webkit)
flyingCarElem.addEventListener("transitionend",function(){
// will be called when the transition has finished.
alert("The car arrived");
});