How to change the background of an element using jQuery method .animate?

2 answers 2

$("#menu a").hover(function(){ $("#menu").css("background", "#f00"); }, function(){ $("#menu").css("background", "#00f"); }); 
  • where is the animate method? - Grundy
  • a bit off topic: I used this method, but I had ajax, and after a chain of requests when returning to the page where this code should work - it did not work, I decided to create a similar question with no seriousness, would you tell me how to deal with this?) - Maximmka
 <div id="element" style="background-color:#fff; width:100px; height:100px;"></div> <script> $("#element").hover(function(){ $(this).animate({ backgroundColor: "#000"}, 1000); }); </script>