<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.progress {
transition: width 10s ease-in-out;
-moz-transition: width 10s ease-in-out;
-webkit-transition: width 10s ease-in-out;
-o-transition: width 10s ease-in-out;
width: 0%;
height: 10px;
background-color: yellowgreen;
}
.end {
width: 100%;
}
</style>
</head>
<body>
<div class="progress"></div>
<script>
window.onload = function () {
var el = document.querySelector('.progress');
var getEventName = function (el) {
var transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd',
'MozTransition' : 'transitionend',
'OTransition' : 'oTransitionEnd otransitionend',
'transition' : 'transitionend'
}
for (var name in transEndEventNames) {
if (el.style[name] !== undefined) {
return transEndEventNames[name];
}
}
}
el.classList.add('end');
el.addEventListener(getEventName(el), function () {
alert('progress = 100%');
}, false);
};
</script>
</body>
</html>