I am trying to use jQuery .animate() to make the background of a div change if it is scrolled more than 100 pixels down a page. I am including jQuery UI, so there is no problem with that, and the code worked before when I used .css().
JS:
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('#top-links-bar').stop().animate({ 'background' : 'linear-gradient(white, gray)' }, 500);
} else {
$('#top-links-bar').stop().animate({ 'background' : 'none' });
}
});
Older JS (worked):
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('#top-links-bar').stop().css('background','linear-gradient(white, gray)');
} else {
$('#top-links-bar').stop().css('background','none');
}
});
backgroundis an animate-able css property, but I do believe there maybe a jQuery color plugin that allows you to animate color (but I think its thebackground-colorproperty you want notbackgroundand I don't think it accepts gradients... only hex values)