I have this code to change the background color of an element (which works fine)
<script>
window.onscroll = function() {
if(document.body.scrollTop == 0) {
jQuery("header#main-header").css('background-color', 'red');
}
}
</script>
Problem is that I need to set the color to red only if the page scroll is between 0 and 100 and set the color to yellow if is bigger than 100.
I tried this in this page: http://temporal-1.d246.dinaserver.com/ but not working:
<script>
window.onscroll = function() {
if(document.body.scrollTop <= 99) {
jQuery("header#main-header").css('background-color', 'red');
}
if(document.body.scrollTop >= 100) {
jQuery("header#main-header").css('background-color', 'yellow');
}
}
</script>