I'm currently working on developing a preliminary landing page for my game using JavaScript. I have integrated a class that overlays my main content, and added an 'onclick' function named fadeOut() for my button in JavaScript. However, the function is not functioning as intended.
<div id="loader1" class="loader">
<img src="assets/zelda-quest-white.png" alt="">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis vulputate nisi ac eros auctor, sed eleifend diam dignissim. Maecenas vel viverra est, vitae volutpat enim. Pellentesque posuere fermentum volutpat. Duis laoreet porttitor dapibus. Phasellus viverra leo augu.</p>
<button type="button" onclick="fadeOut()">Fade Out</button>
</div>
I've defined a class called .loader with an opacity transition set to 2s.
.loader {
position: fixed;
z-index: 99;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000000;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
transition: opacity 2s;
}
Additionally, in JavaScript:
function fadeOut() {
const square = document.querySelector('#loader1')
square.style.opacity = '0'
}
This element serves as the page loader. https://i.sstatic.net/iHFYi.png
The goal is to make this content disappear upon loading so that the main content becomes visible. https://i.sstatic.net/CZuFC.jpg