|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all,
Here's the basics on what I'm trying to do. I've got three tabs, with the first one selected on page load. It has a 'selected' class that has a certain background color and text color. If the user clicks on one of the other tabs, I would like for that newly selected tab to now take on the 'selected' class attributes while the other two non active or non selected tabs have another class attributes. Here's some of what I've got: css Code:
.tabs a{
float: left;
display: block;
font: bold 11px Arial;
color: white;
text-decoration: none;
margin: 0 1px 0 0; /*Margin between each menu item*/
padding: 5px 10px;
background-color: black;
border-top: 1px solid white;
}
.tabs a.selected{ /*currently selected tab*/
background-color: #7D9EC0;
color: white;
border-color: #7D9EC0;
}
.tabs a:hover{
background-color: #e8eff6;
color: #000000;
}
html Code:
<div id="tabs" class="theClass">
<ul>
<li><a href="#" rel="tab1" class="selected" "onClick="displayHPTabContent('t1')">Tab 1</a></li>
<li><a href="#" rel="tab2" onClick="displayHPTabContent('t2')">Tab 2</a></li>
<li><a href="#" rel="tab3" onClick="displayHPTabContent('t3')">Tab 3</a></li>
</ul>
</div>
the javascript: Code:
function displayHPTabContent(the_sub) {
if (the_sub == "t2") {
document.getElementById('tab2').style.display = "";
document.getElementById('tab1').style.display = "none";
document.getElementById('tab3').style.display = "none";
} else if (the_sub == "t3") {
document.getElementById('tab2').style.display = "none";
document.getElementById('tab1').style.display = "none";
document.getElementById('tab3').style.display = "";
document.getElementById('tab2').style.backgroundColor="yellow"; // **This is the part I'm not getting **
alert (document.getElementById('flowertabs').attributes);
} else if (the_sub == "t1") {
document.getElementById('tab2').style.display = "none";
document.getElementById('tab1').style.display = "";
document.getElementById('tab3').style.display = "none";
}
}
some more 'content' html below the tabs: Code:
<div id="tab1"> stuff </div> <div id="tab2"> stuff </div> <div id="tab3"> stuff </div> My question is, how do I reference the 'rel' for the clicked on <a href> so that I can turn it's class to selected and make sure the others are of the non selected class? Or, is there some other way? Thanks! |
|
#2
|
|||||
|
|||||
|
Ok, a quick example.
Javascript Code:
|
|
#3
|
|||
|
|||
|
excellent...thanks for the response and the suggestion PHP-Newb!
|
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > Change <a href> class type once selected? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|