<div>Hello people</div>
<script type="text/javascript">
var SmoothOpacity = (function() {
var test = document.createElement( 'div' );
test.innerHTML = "<a style='opacity:.55;'></a>";
var a = test.getElementsByTagName( "a" )[ 0 ],
supportOpacity = /^0.55/.test( a.style.opacity );
return function( element, start, end, step, speed, onComplete ) {
var rev = start > end ? true : false,
interval = setInterval( function(){
if ( rev && start <= end || !rev && start >= end ) {
start = end;
clearInterval( interval );
}
if ( supportOpacity ) {
element.style.opacity = start;
} else {
element.style.filter = 'alpha(opacity=' + start * 100 + ')';
}
onComplete && start == end && onComplete();
start += rev ? -step : step;
}, speed );
}
})();
SmoothOpacity(document.body, 1, 0, .08, 100, function(){
SmoothOpacity(document.body, 0, 1, .08, 100, function(){alert('Done!')});
});
</script>