TheBram
Legacy Member
hallo, ik probeer een tab menuutje te maken met JS, alles lukt goed en wel maar ik zou graag zoals ik met css al eens heb gedaan de 'here' style gebruiken, zodat bij de tab die ik aanklik het onderste lijntje verandert in de achtergrondkleur, momenteel hovert hij de tab gewoon
deze code gebruikte ik met css om het te verwezelijken
dit is mijn huidige code:
hoe kan ik het in mijn JS script verwerken?
merci
deze code gebruikte ik met css om het te verwezelijken
#tabs ul li.here {
border-bottom: 1px solid #ffc;
list-style: none;
display: inline;
}
dit is mijn huidige code:
<html>
<head>
<title></title>
<script language="JavaScript">
var currentPanel;
function showPanel(panelNum) {
//hide visible panel, show selected panel,
//set tab
if (currentPanel != null) {
hidePanel();
}
document.getElementById
('panel'+panelNum).style.visibility = 'visible';
currentPanel = panelNum;
setState(panelNum);
}
function hidePanel() {
//hide visible panel, unhilite tab
document.getElementById
('panel'+currentPanel).style.visibility =
'hidden';
document.getElementById
('tab'+currentPanel).style.backgroundColor =
'#ffffff';
document.getElementById
('tab'+currentPanel).style.color = 'navy';
}
function setState(tabNum) {
if (tabNum==currentPanel) {
document.getElementById
('tab'+tabNum).style.backgroundColor =
'#ddddff';
document.getElementById
('tab'+tabNum).style.color = 'red';
}
else {
document.getElementById
('tab'+tabNum).style.backgroundColor =
'#ffffff';
document.getElementById
('tab'+tabNum).style.color = 'navy';
}
}
function hover(tab) {
tab.style.backgroundColor = 'ddddff';
}
</script>
<style>
.tab{
color: navy;
background-color: white;
border: thin solid navy;
position: absolute;
top: 10;
width: 140;
text-align: center;
font: 9pt Verdana,sans-serif;
z-index: 2;
padding: 3;
cursor: pointer;
cursor: hand;
}
.panel{
position: absolute;
top: 32;
left: 10;
width: 95%;
z-index: 1;
height: 85%;
visibility: hidden;
font: 12pt Verdana,sans-serif;
color: navy;
border: thin solid navy;
padding: 10;
overflow: auto;
}
</style>
</head>
<body onLoad="showPanel(1)">
<div id="tab1" class="tab" style="left: 10;"
onClick = "showPanel(1);"
onMouseOver="hover(this);"
onMouseOut="setState(1)">Tab One</div>
<div id="tab2" class="tab" style="left: 150;"
onClick = "showPanel(2);"
onMouseOver="hover(this);"
onMouseOut="setState(2)">Tab Two</div>
<div id="tab3" class="tab" style="left: 290;"
onClick = "showPanel(3);"
onMouseOver="hover(this);"
onMouseOut="setState(3)">Tab Three</div>
<div id="tab4" class="tab" style="left: 430;"
onClick = "showPanel(4);"
onMouseOver="hover(this);"
onMouseOut="setState(4)">Tab Four</div>
<div id="tab5" class="tab" style="left: 570;"
onClick = "showPanel(5);"
onMouseOver="hover(this);"
onMouseOut="setState(5)">Tab Five</div>
<div id="panel1" class="panel">Panel 1</div>
<div id="panel2" class="panel">Panel 2</div>
<div id="panel3" class="panel">Panel 3</div>
<div id="panel4" class="panel">Panel 4</div>
<div id="panel5" class="panel">Panel 5</div>
</body>
</html>
hoe kan ik het in mijn JS script verwerken?
merci
sry ma kben nog maar en beginneling