javascript - How can call a selected class on window.onload -
i have made simple javascript during window.onload fades in body when finished.
i want create overlay specific class instead shall reverse. want overlay fade out , after animation object destroyed or set display:none.
<style> body { opacity: 0; transition: opacity 500ms ease-in-out; } </style> <script>window.onload = function() {settimeout(function(){document.body.style.opacity="100";},500);};</script> how accomplish in best way possible?
you asked jquery tag anwser jquery code.
$(function() { var $overlay = $('#overlay'); $overlay.css('opacity', 0); settimeout(function() { $overlay.remove(); }, 500); }); #overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background-color: white; transition: opacity 500ms; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div> text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text </div> <div id="overlay"></div>
Comments
Post a Comment