I have a code snippet that I use in my websites to display a Call to Action btn when the user scrolls down a webpage. But its not working in one of my websites. I have researched and couldn't find an error. Here's the link to the page I am using this code. Why JS is not adding the class "atcbottomactive" to the element?
$(window).scroll(function() {
var scroll = $(window).scrollTop();
if (scroll >= 1100) {
$(".atcbottom").addClass("atcbottomactive");
} else {
$(".atcbottom").removeClass("atcbottomactive");
}
});
@media only screen and (min-width:1000px) {
.atcbottom {
display: none!important
}
.btnn {
margin-top: -60px!important
}
}
@media only screen and (max-width:999px) {
.atcbottomactivepopup {
margin-bottom: 60px
}
}
.atcbottom {
height: 60px;
width: 100vw;
position: fixed;
z-index: 102;
background: #fff;
bottom: -100px;
transition: 2s;
left: 0;
}
.atcbtn {
height: 40px;
background: #4cae4c;
width: 90vw;
margin-top: 10px;
margin-left: 5vw;
border: none;
color: #fff;
font-size: 20px;
}
.atcbottomactive {
bottom: 0
}
<div style="height:1000px; width: 100%; background: blue">
<div class='atcbottom'>
<div class="container">
<div class="row">
<a href="#ProductPrice-product-template">
<button type="button" class="atcbtn">Call to action</button>
</a>
</div>
</div>
</div>
</div>
