The value of backgoundColor needs to be described in .css (). Example:
.css({backgroundColor: "#ffe", borderLeft: "5px solid #ccc" })
Option:
$(document).ready(function() { $(window).scroll(function() { var top = $(document).scrollTop(); if (top > 0) { $(".header").css("backgroundColor", "#ffffff"); } else { $(".header").css("backgroundColor", "none"); } }); });
A more detailed description is presented here .
Adding to the answer: background-color cannot be changed via animate() until the jQuery.Color plugin is connected
You can also connect the library and try to play this way:
Option 2:
<!-- include Google's AJAX API loader --> <script src="http://www.google.com/jsapi"></script> <!-- load JQuery and UI from Google (need to use UI to animate colors) --> <script type="text/javascript"> google.load("jqueryui", "1.5.2"); </script> <script type="text/javascript"> $(document).ready(function() { $(window).scroll(function() { var top = $(document).scrollTop(); if (top > 0) { $(".header").stop().animate({backgroundColor: '#ffffff'}, 1000); } else { $(".header").stop().animate({backgroundColor: 'none'}, 1000); } }); }); </script>
initial,inherit,unsetinstead ofnone- stackanon