I can't understand why this code don't works correctly:
$(document).ready(function() {
$(window).scroll(function() {
console.log($(window).scrollTop())
if ($(window).scrollTop() < 626) {
$('#shop-cart').addClass('shopcart-hidden').removeClass('shopcart-fixed');
}
if ($(window).scrollTop() > 625) {
$('#shop-cart').removeClass('shopcart-hidden').addClass('shopcart-fixed');
}
});
});
The idea is to hide shopping cart information when page loads and to show it only when user scrolls down a little bit. If user scrolls up the information should be hidden again. I've got div with id - shop-cart and some php code inside it, also I've got CSS class defined in style.css:
#shop-cart {
background:#757575;
}
.shopcart-fixed {
float:right;
right:0;
z-index:100;
position:fixed;
}
.shopcart-hidden {
display:none;
}
if? Useelsefor the second one!