背景图片不淡入

Background image not fading in

我一直在试图弄清楚为什么我的背景图片没有淡入。我试过使用 css/jquery 和 w3 路线。我可以看到背景图片确实出现了,而且我已经检查过 jquery 代码是否对我嵌套在 body 标签中的任何标签有效。我已经阅读了其他帖子,但它们没有帮助。

$(document).ready(function(){
    $("body").hide().fadeIn(3000);
});
body {
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    background-image: url('../images/index.jpeg');
}
<!DOCTYPE html>
<html>
<head>
<title>TITLE</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="css/styles.css">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="scripts/myScript.js"></script>
</head>


<body>


</body>
</html> 

您可以使用setTimout

$(document).ready(function(){
    setTimeout(function() {
    $("body").css("background-image", "url('https://s13.favim.com/orig/170403/aesthetic-forest-nature-photography-Favim.com-5145568.png')");
}, 2000);
});
body {
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>just text here</p>

$(document).ready(function() {
  $("body").hide().fadeIn(3000);
});
html,body{
  margin:0;
  padding:0;
}

div{
  width:100%;
  height: 100vh;
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  background-image: url('http://www.nationalgeographic.com/content/dam/science/photos/000/009/940.jpg');
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
</div>