Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery animate the page background-color on page load

I'm attempting to just change the background colour of a webpage upon page load. I see no reason why this shouldn't work, "body" is the correct element I wish to manipulate. I am using http://docs.jquery.com/UI/Effects/animate as a reference.

$(document).ready(function(){
    $("body").animate({ backgroundColor: "#000000" }, 1000);
});
like image 345
johnsonwi Avatar asked Dec 20 '22 19:12

johnsonwi


1 Answers

Working demo http://jsfiddle.net/aqrvA/8/

Add Jquery ui library as well please Rest will work like a rocket! < Your code is fine >

Jquery UI link: http://jqueryui.com/

Hope this helps, :)

Script:

  <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
  <script type="text/javascript" src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>

code

$(document).ready(function(){
    $("html body").animate({ backgroundColor: "#000000" }, 1000);
});​
like image 182
Tats_innit Avatar answered Jan 06 '23 07:01

Tats_innit