Reputation: 14764
I'm trying to stop a preloader after the page has been loaded.
Let's say we take the preloader below.
CSS:
body {
background: #eaecfa;
}
.loader {
width: 250px;
height: 50px;
line-height: 50px;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
font-family: helvetica, arial, sans-serif;
text-transform: uppercase;
font-weight: 900;
color: #ce4233;
letter-spacing: 0.2em;
}
.loader::before, .loader::after {
content: "";
display: block;
width: 15px;
height: 15px;
background: #ce4233;
position: absolute;
-webkit-animation: load .7s infinite alternate ease-in-out;
animation: load .7s infinite alternate ease-in-out;
}
.loader::before {
top: 0;
}
.loader::after {
bottom: 0;
}
@-webkit-keyframes load {
0% {
left: 0;
height: 30px;
width: 15px;
}
50% {
height: 8px;
width: 40px;
}
100% {
left: 235px;
height: 30px;
width: 15px;
}
}
@keyframes load {
0% {
left: 0;
height: 30px;
width: 15px;
}
50% {
height: 8px;
width: 40px;
}
100% {
left: 235px;
height: 30px;
width: 15px;
}
}
HTML:
<div class="loader">Loading...</div>
Why does the following JS code work, i.e. I get the alert:
$(document).ready(function(){
$(window).load(function(){
alert("This can run");
});
})
And the same code with a changed line doesn't stop the preloader?
$(document).ready(function(){
$(window).load(function(){
$("loader").remove();
});
})
I'm a complete newbie to web development, however have tried many other answers here, but I cannot get any of them to work.
Upvotes: 1
Views: 1992
Reputation: 678
You're missing a .
at the $("loader").remove()
:)
$(document).ready(function(){
$(window).load(function(){
$(".loader").remove();
});
})
Upvotes: 3