IE9 jquery Load function problem
This is the full code what i am looking for.
First black screen will come, after that logo loads with fadein affect. after 2sec the full div will be faded out.
<script type="text/javascript">
$(document).ready(function() {
$('#splash-logo').hide()
.load(function () {
$('#splash-logo').fadeIn(2000, function() {
$('#splash').fadeOut(1000);
开发者_运维问答 });
});
});
</script>
<style type="text/css">
#splash{
background:#000;
width:100%;
height:100%;
position:absolute;
z-index:9999;
text-align:center;
padding-top:98px;
}
body{
margin:0;
}
</style>
<div id="splash">
<img src="" id="#splash-logo" />
</div>
The elements you're working with haven't been loaded when window
is loaded. They only become available once the DOM has fully loaded.
As such, change your initial load
method to be applied to the document
object, rather than the window
object:
$(document).ready(function() {
$('#splash-logo').hide()
.load(function () {
$('#splash-logo').fadeIn(2000, function() {
$('#splash').fadeOut(1000);
});
});
});
Change window
to document
$(document).ready(function() {
$('#splash-logo').hide()
.load(function () {
$('#splash-logo').fadeIn(2000, function() {
$('#splash').fadeOut(1000);
});
});
});
If you want to use window
, you have to use the JQuery load
function instead of ready
$(window).load(function () {
// run code
});
精彩评论