Here is the html:
<div id="wrapper">
<ul class="tabs">
<li class="active"><a href="#tab1">Tab 1</a></li>
<li class=""><a href="#tab2">Tab 2</a></li>
<li class=""><a href="#tab3">Tab 3</a></li>
</ul>
<div class="tab-container">
<div id="tab1" class="tab-content" style="display: none; ">
<h2>Title</h2>
<p>Text</p>
<p><a href="http://fakelink.html"><img src="btn.png"></a></p>
</div>
</div>
<div id="tab2" class="tab-content" style="display: none; ">
<h2>Title</h2>
<p>Text</p>
<p><a href="http://fakelink.html"><img src="btn.png"></a></p>
</div>
</div>
<div id="tab3" class="tab-content" style="display: none; ">
<h2>Title</h2>
<p>Text</p>
<p><a href="http://fakelink.html"><img src="btn.png"></a></p>
</div>
</div>
</div>
</div>
Script:
(function($) {
$(document).ready(function() {
$(".tab-content").hide();
$("#tab1").show();
//On Click Event
$("ul.tabs li").mouseover(function() {
$("ul.tabs li").removeClass("active");
$(this).addClass("active");
$(".tab-content").hide();
var activeTab = $(this).find("a").attr("href");
$(activeTab).fadeIn();
return false;
});
});
})(jQuery);
Everything works fine for the tabs, the li class changes to active when I mouseover. However the tab-content does not change from display:none to display:block. :/
demo jsBin
the jQ:
THe FIXED HTML: (I removed ID and other unneeded stuff.)