Javascript: Body background
I'm not that good with Javascript but because I felt I needed it for
making the more modern websites I decided to make a function that changes
the body background image after every 10 seconds.
function Background()
{
var Background_Stage;
switch(Background_Stage)
{
case 0:
{
$('body').css.toogle("slide").('background', '#000
url(../../Styles/Callum_Project1/Images/BACKGROUND_1_TEST.png)
no-repeat');
Background_Stage++;
setInterval(function(){Background()},10000);
}
case 1:
{
$('body').css.toogle("slide").('background', '#000
url(../../Styles/Callum_Project1/Images/BACKGROUND_2_TEST.png)
no-repeat');
Background_Stage++;
setInterval(function(){Background()},10000);
}
case 2:
{
$('body').css.toogle("slide").('background', '#000
url(../../Styles/Callum_Project1/Images/BACKGROUND_2_TEST.png)
no-repeat');
Background_Stage = 0;//Reset
setInterval(function(){Background()},10000);
}
}
}
However hen I did something like this
<body onload="Background()"></body>
It doesn't seem to do anything, this might be a dumb thing to ask for help
with but this is the first I did when I was learning JavaScript, I should
say that I used jQuery for most of this.
No comments:
Post a Comment