I have a jQuery tabs slider that auto rotates and depending on the slide it will adjust the background of the <div>
element it is in. Auto rotate goes fine, the correct background is loaded, but when I manually click the tabs, it doesn't take the correct values. It's almost like it's 1 behind.
Below is the HTML code
<div id="featured">
<ul class="ui-tabs-nav">
<li class="ui-tabs-nav-item">
<a href="#fragment-1" id="active-1" class=""><span style="background-color: #94d1e3; background-image: url(uploads/tx_background_img/banner_bg2.jpg); display:none;"></span><span>Test</span></a>
</li>
<li class="ui-tabs-nav-item ui-tabs-selected">
<a href="#fragment-2" id="active-2" class=""><span style="background-color: #e6c8a6; background-image: url(uploads/tx_background_img/banner_bg.png); display:none;"></span><span>Test1</span></a>
</li>
<li class="ui-tabs-nav-item">
<a href="#fragment-3" id="active-3" class=""><span style="background-color: #94d1e3; background-image: url(uploads/tx_background_img/banner_bg2_01.jpg); display:none;"></span><span>Test2</span></a>
</li>
<li class="ui-tabs-nav-item">
<a href="#fragment-4" id="active-4" class=""><span style="background-color: #e6c8a6; background-image: url(uploads/tx_background_img/banner_bg_01.png); display:none;"></span><span>test3</span></a>
</li>
</ul>
<div>
<img src="fileadmin/templates/images/inner_banner_top_corner.png" alt="">
</div>
<div class="banner_slide">
<div id="fragment-1" class="ui-tabs-panel ui-tabs-hide" style="">
<h1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the
1500s, when an unknown printer took a galley of type and scrambled it to
make a type specimen book. It has survived not only five centuries, but
also the</h1>
<div class="banner_img">
<img src="uploads/tx_header_img/banner_slide_bg.png" width="256" height="279"
border="0" class="customer_img" alt="">
</div>
<div class="banner_btn">
<a href="/klanten/"><img src="fileadmin/templates/images/banner_btn.png" alt=""></a>
</div>
</div>
<div id="fragment-2" class="ui-tabs-panel" style="">
<h1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the
1500s, when an unknown printer took a galley of type and scrambled it to
make a type specimen book. It has survived not only five centuries, but
also the</h1>
<div class="banner_img">
<img src="uploads/tx_header_img/banner_slide_bg_01.png" width="256" height="279"
border="0" class="customer_img" alt="">
</div>
<div class="banner_btn">
<a href="/"><img src="fileadmin/templates/images/banner_btn.png" alt=""></a>
</div>
</div>
<div id="fragment-3" class="ui-tabs-panel ui-tabs-hide" style="">
<h1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the
1500s, when an unknown printer took a galley of type and scrambled it to
make a type specimen book. It has survived not only five centuries, but
also the</h1>
<div class="banner_img">
<img src="uploads/tx_header_img/banner_slide_bg_02.png" width="256" height="279"
border="0" class="customer_img" alt="">
</div>
<div class="banner_btn">
<a href="/contact/"><img src="fileadmin/templates/images/banner_btn.png" alt=""></a>
</div>
</div>
<div id="fragment-4" class="ui-tabs-panel ui-tabs-hide" style="">
<h1>Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the
1500s, when an unknown printer took a galley of type and scrambled it to
make a type specimen book. It has survived not only five centuries, but
also the</h1>
<div class="banner_img">
<img src="uploads/tx_header_img/banner_slide_bg_03.png" width="256" height="279"
border="0" class="customer_img" alt="">
</div>
<div class="banner_btn">
<a href="/contact/"><img src="fileadmin/templates/images/banner_btn.png" alt=""></a>
</div>
</div>
</div>
<div>
<img src="fileadmin/templates/images/inner_banner_bottom_corner.png" alt="">
</div>
</div>
Below is the jQuery
$(document).ready(function() {
var ac1 = false;
//$("#featured > ul").tabs({fx:{opacity: ""},event: "mouseover"}).tabs("option", 5000, false);
var $tabs = $("#featured > ul").tabs({
fx: {
opacity: "toggle"
}
}).tabs("rotate", 5000, true);
var id = $('.ui-tabs-selected a').attr('id');
var colorCode = $("#" + id + " span").css('backgroundColor');
$(".banner_color").css("backgroundColor", colorCode);
var imageCode = $("#" + id + " span").css('backgroundImage');
$("#wsnSlider").css("backgroundImage", imageCode);
$("#featured > ul").bind('tabsselect', function(event, ui) {
var id = $('.ui-tabs-selected a').attr('id');
var id2 = parseInt(id.replace("active-", "")) || 0;
id2 = id2 + 1;
if (id2 == 5) {
id2 = 1;
}
console.log(id2);
var colorCode = $("#active-" + id2 + " span").css('backgroundColor');
$(".banner_color").css("backgroundColor", colorCode);
var imageCode = $("#active-" + id2 + " span").css('backgroundImage');
$("#wsnSlider").css("backgroundImage", imageCode);
console.log(colorCode + " " + imageCode + " ");
});
});