gpt4 book ai didi

javascript - jQuery加载导致body变白

转载 作者:行者123 更新时间:2023-11-28 17:59:37 25 4
gpt4 key购买 nike

我只是通过 jQuery 的 fadeOut/fadeInload 功能从欢迎页面过渡到包含内容的新页面。两个页面都加载了相同的 CSS 和框架,并且都有黑色背景。但是,当它加载第二页时,背景变为白色。

这不是像此处提出的其他问题那样的“白色闪光”。从字面上看, body 变成白色并保持这种状态。任何想法为什么或我做错了什么?我确定我忽略了一些非常基本的东西。

index.html:

<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(function(){
$('#go').click(function() {
$('html').fadeOut(2500, function() {
$(this).load('second.html', function() {
$(this).fadeIn(2500);
});
});
return false;
});
})
});
</script>
</head>
<body>
<a id="go">Go!</a>
</body>
</html>

second.html:

<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
</head>
<body>&nbsp;</body>
</html>

样式.css:

body {
background: #000000;
}

最佳答案

分析...

$('#go').click(function() { // clicking go...
$('html').fadeOut(2500, function() { // html fade out....
$(this).load('second.html', function() { // html content changes...
$(this).fadeIn(2500); // this line can't run... cause entire html changes... including the <head> that has the script... this line is goodbye...
});
});
return false;
});

建议,只更改<body>的内容标记...

关于javascript - jQuery加载导致body变白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20737197/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com