Change Div Color After Scrolling 15% Down With Jquery
I have this jquery code below which makes a div scroll. But I would also like it to change the div color to #32200F when is down 15% from the top.THen return to the original barckg
Solution 1:
Try:
$(document).ready(function () {
var $scrollingDiv = $("#navbar");
$(window).scroll(function () {
$scrollingDiv.stop()
.animate({
"marginTop": ($(window).scrollTop() + 0) + "px"
}, "slow");
$scrollingDiv.css("background-color", (($(window).scrollTop() / $(document).height()) > 0.15) ? "orange" : "");
});
});
Post a Comment for "Change Div Color After Scrolling 15% Down With Jquery"