Answer the question
In order to leave comments, you need to log in
Why does javascript load 1 but background-image 2?
javascript just started learning.
There is a tag script at the end of the body, but the background does not have time to load. How to fix ?
Like this
- only locally, when 1 time offers to enter there is no background there and loads after the script is completed.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Battle of the ship</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="wrapper">
<h1 class="mainTitle">Battle of ship</h1>
</div>
<script src="code.js"></script>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
You can check if the background image is loaded, and after it is loaded, already run your script
jsfiddle.net/gmzSG/80
but the background does not have time to load.
I'm afraid to even imagine what kind of background you have there
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question