Javascript jQuery加载导致主体变为白色
我只是通过jQuery的Javascript jQuery加载导致主体变为白色,javascript,jquery,html,css,ajax,Javascript,Jquery,Html,Css,Ajax,我只是通过jQuery的fadeOut/fadeIn和load功能,从一个欢迎页面过渡到一个包含内容的新页面。两个页面都加载了相同的CSS和框架,并且都有黑色背景。但是,当它加载第二页时,背景变为白色 这不是一个“白色闪光”像其他问题在这里问。从字面上看,身体会变成白色并保持这种状态。知道我做错了什么吗?我肯定我忽略了一些非常基本的东西 index.html: <!DOCTYPE html> <head> <link rel="stylesheet" t
fadeOut/fadeIn
和load
功能,从一个欢迎页面过渡到一个包含内容的新页面。两个页面都加载了相同的CSS和框架,并且都有黑色背景。但是,当它加载第二页时,背景变为白色
这不是一个“白色闪光”像其他问题在这里问。从字面上看,身体会变成白色并保持这种状态。知道我做错了什么吗?我肯定我忽略了一些非常基本的东西
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>
<!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> </body>
</html>
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;
});
$('#go')。单击(函数(){//单击go。。。
$('html').fadeOut(2500,function(){//html淡出…)。。。。
$(this.load('second.html',function(){//html内容更改。。。
$(this).fadeIn(2500);//此行无法运行…导致整个html更改…包括包含脚本的…此行是再见。。。
});
});
返回false;
});
建议,只更改
标签的内容…问题是否清楚?如果要隐藏html
元素,请创建一个包装器元素并隐藏它。哇。脸掌。请拿走我所有的徽章。$(function(){
是$(document)的缩写。准备好了(function(){
),所以,把这两个徽章中的任何人都除掉。