I have css hover over the images for my tabs and I am trying to change the class from .how to .how_on when I click on the HOW image.
My tabs
HOW | WHAT | WHEN | WHO | Why
I have classes for each (.how, .how_on), (.what, .what_on), etc.
Can I make jQuery add _on for the original class name using click (function () {});
HTML:
<div id="tab_container">
<ul class="tabs">
<li><a class="how_on" href="#how">How</a></li>
<li><a class="why" href="#why">Why</a></li>
<li><a class="what" href="#what">What</a></li>
<li><a class="who" href="#who">Who</a></li>
<li><a class="when" href="#when">When</a></li>
</ul>
<p><img src="images/tab_top.jpg" width="864px" height="6px" alt="" border="0" /></p>
</div>
<div class="tab_body">
<div id="how" class="tab">
<strong>HOW IT WORKS:</strong>
</div>
Jquery:
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".tab:not(:first)").hide();
jQuery(".tab:first").show();
jQuery(".tabs a").click(function(){
stringref = jQuery(this).attr("href").split('#')[1];
jQuery('.tab:not(#'+stringref+')').hide();
if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0") {
jQuery('.tab#' + stringref).show();
}
else
jQuery('.tab#' + stringref).fadeIn();
return false;
});
});
</script>
CSS
.tabs
{
width: 683px;
height: 29px;
padding: 0;
margin: 0;
display: inline;
float: left;
overflow: hidden;
list-style-type: none;
}
.tabs li
{
margin: 0;
padding: 0;
display: inline;
float: left;
}
.tabs a { background-position: 0 -58px;}
.tabs .on a { background-position: 0 -29px;}
.how,
a.how:link,
a.how:visited
{
float: left;
display: inline;
width: 135px;
height: 29px;
margin: 0;
text-decoration: none;
text-indent: -99999px;
overflow: hidden;
background-image: url("../images/how_tab.jpg");
}
source
share