dniwebdesign
12-03-2010, 06:52 PM
I have a navigation list set up as
<ul id="Alpha">
<li id="?"><a href="#alpha" rel="#">#</a></li>
<li id="A"><a href="#alpha" rel="A">A</a></li>
<li id="B"><a href="#alpha" rel="B">B</a></li>
<li id="C"><a href="#alpha" rel="C">C</a></li>
// And so on...
Now... I want to automatically set the class of say B on load to 'currentpage'. I get the current page from the query string via php
<?php if(!empty($_GET["cat"])) {
echo 'highlight = "'.strtoupper($_GET["cat"]).'";';
}
else {
echo 'highlight = "A";';
}
?>
which in turns either put the highlight variable to the value of $_GET['cat'] or by default A if nothing else is specified.
How do I set the class of the link?
I thought something like
$("#Alpha a").attr('rel',highlight).attr('class','currentpage');
but it just highlights everything. Seems like something simple but I can't figure it out and am running out of time. :-)
<ul id="Alpha">
<li id="?"><a href="#alpha" rel="#">#</a></li>
<li id="A"><a href="#alpha" rel="A">A</a></li>
<li id="B"><a href="#alpha" rel="B">B</a></li>
<li id="C"><a href="#alpha" rel="C">C</a></li>
// And so on...
Now... I want to automatically set the class of say B on load to 'currentpage'. I get the current page from the query string via php
<?php if(!empty($_GET["cat"])) {
echo 'highlight = "'.strtoupper($_GET["cat"]).'";';
}
else {
echo 'highlight = "A";';
}
?>
which in turns either put the highlight variable to the value of $_GET['cat'] or by default A if nothing else is specified.
How do I set the class of the link?
I thought something like
$("#Alpha a").attr('rel',highlight).attr('class','currentpage');
but it just highlights everything. Seems like something simple but I can't figure it out and am running out of time. :-)