I have a built page which I cant really touch the HTML structure so read carefully:
First:
That page I have has a background-image: url('main-1.jpg'); I want it to change every 3 seconds to main-2.jpg and main-3.jpg.
Second:
I have two arrow buttons on the sides of the page with the classes: l-arrow (left-arrow) and r-arrow (right-arrow).
All image changes have to include the fade effect in them somehow!
I can't stack images on each other since it's the main div
This is the jQuery I have till now and even now, the buttons aren't working:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var count = 1;
$(".r-arrow").click(function{
if ( count == 1 ) {
count = 2;
$('.main').css("background-image", "url(main-2.jpg)");
} else if (count == 2) {
count == 3;
$('.main').css("background-image", "url(main-3.jpg)");
} else if (count == 3) {
count == 1;
$('.main').css("background-image", "url(main-1.jpg)");
}
console.log(count);
})
$(".l-arrow").click(function{
if ( count == 1 ) {
count = 3;
$('.main').css("background-image", "url(main-3.jpg)");
} else if (count == 2) {
count == 1;
$('.main').css("background-image", "url(main-1.jpg)");
} else if (count == 3) {
count == 2;
$('.main').css("background-image", "url(main-2.jpg)");
}
})
});
</script>
What can be the problem ?
I added a jsfiddle as example: http://jsfiddle.net/4eyv7td9/