M
MLD
PLEASE HELP!
I would like to include a UL as a menu, styled by an included CSS
Style Sheet.
The problem I am having is how do I dynamically set the "active" page
class using JavaScript to change each time I click on a new list
item? I have found a bunch of examples but none that really
accomplish what I need.
As I choose from the list, I want the current page selected, evm.htm
for example, to have the following automatically populate using JS so
that the included menu HTML would look like this after tab 2 is
selected:
<ul id="menu">
<li><a href="home.htm">Home</a></li>
<li class="active"><a href="evm.htm">EVM</a></li>
<li><a href="finance.shtml">Finance</a></li>
<li><a href="investments.shtml">Investments</a></li>
<li><a href="OpsAdmin.shtml">Administration</a></li>
<li><a href="subsidiaries.shtml">Subsidiaries</a></li>
</ul>
Home Page: index.shtml
Include File: <!--#include file="menu.html" -->
menu.html
<ul id="menu">
<li><a href="home.htm">Home</a></li>
<li><a href="evm.htm">EVM</a></li>
<li><a href="finance.shtml">Finance</a></li>
<li><a href="investments.shtml">Investments</a></li>
<li><a href="OpsAdmin.shtml">Administration</a></li>
<li><a href="subsidiaries.shtml">Subsidiaries</a></li>
</ul>
CSS (separate file as well)
#menu {
float: right;
background: #fff url(../images/barul.gif) no-repeat bottom right;
color: #808080;
padding: 18px 1px 11px 0;
margin: 0;
}
#menu li{
list-style-type:none;
}
#menu li a{
color:#666;
background:url(baractive.gif) transparent top right no-repeat;
display:block;
padding:0 10px 0 0;
}
#menu li.active,
#menu li.over,
#menu li:hover
{
color: #0066FF;
background: #f8f8f8;
background-color: #EAEAEA;
}
#menu li strong,
ul#menu li.active a{
background: #fff url(../images/baractive_blue4.gif) no-repeat bottom
left;
}
ul#menu li.over a,
ul#menu li:hover a
{
background: #fff url(../images/baractive_blue4.gif) no-repeat bottom
left;
font-weight: bolder;
padding: 14px 18px 14px 18px;
color:#000000;
background-color: #FFFFFF;
text-decoration: none; background:none;
}
I would like to include a UL as a menu, styled by an included CSS
Style Sheet.
The problem I am having is how do I dynamically set the "active" page
class using JavaScript to change each time I click on a new list
item? I have found a bunch of examples but none that really
accomplish what I need.
As I choose from the list, I want the current page selected, evm.htm
for example, to have the following automatically populate using JS so
that the included menu HTML would look like this after tab 2 is
selected:
<ul id="menu">
<li><a href="home.htm">Home</a></li>
<li class="active"><a href="evm.htm">EVM</a></li>
<li><a href="finance.shtml">Finance</a></li>
<li><a href="investments.shtml">Investments</a></li>
<li><a href="OpsAdmin.shtml">Administration</a></li>
<li><a href="subsidiaries.shtml">Subsidiaries</a></li>
</ul>
Home Page: index.shtml
Include File: <!--#include file="menu.html" -->
menu.html
<ul id="menu">
<li><a href="home.htm">Home</a></li>
<li><a href="evm.htm">EVM</a></li>
<li><a href="finance.shtml">Finance</a></li>
<li><a href="investments.shtml">Investments</a></li>
<li><a href="OpsAdmin.shtml">Administration</a></li>
<li><a href="subsidiaries.shtml">Subsidiaries</a></li>
</ul>
CSS (separate file as well)
#menu {
float: right;
background: #fff url(../images/barul.gif) no-repeat bottom right;
color: #808080;
padding: 18px 1px 11px 0;
margin: 0;
}
#menu li{
list-style-type:none;
}
#menu li a{
color:#666;
background:url(baractive.gif) transparent top right no-repeat;
display:block;
padding:0 10px 0 0;
}
#menu li.active,
#menu li.over,
#menu li:hover
{
color: #0066FF;
background: #f8f8f8;
background-color: #EAEAEA;
}
#menu li strong,
ul#menu li.active a{
background: #fff url(../images/baractive_blue4.gif) no-repeat bottom
left;
}
ul#menu li.over a,
ul#menu li:hover a
{
background: #fff url(../images/baractive_blue4.gif) no-repeat bottom
left;
font-weight: bolder;
padding: 14px 18px 14px 18px;
color:#000000;
background-color: #FFFFFF;
text-decoration: none; background:none;
}