Instead of using the background
property for a background image, I have opted for a different style. Here is how I implemented it:
<div id="bg">
<img id="bgChange" src="image/image.jpg" />
</div>
This is the corresponding CSS code:
#bg {
position: fixed;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
}
#bg > div {
position: absolute ;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
min-width: 50%;
min-height: 50%;
}
To dynamically change the image source, I used this simple JavaScript function:
var imageRotating = document.getElementById("bgChange");
var i = 0;
setInterval(function imageRotator() {
imageRotating.setAttribute("src", "image/image" + ++i + ".jpg");
if (i == 3) { i = -1; }
}, 5000);
Now my question is:
How can I incorporate the .fadeOut()
method in this script using jQuery? Since I am new to jQuery, I would appreciate a detailed explanation.