PDA

View Full Version : First-Child/Last-Child



sundevil67
01-27-2009, 06:55 PM
I have a menu here (http://adamfialkov.com/staging/header_test.html)...it relies on the <a> to change the background-position of the image and add a bottom-border to the surrounding <li> by adding a class. I need to add support for browsers that will not support the first-child/last-child pseudo classes...so I would like to add a style declaration (instead of a class change; <style.paddingLeft...> so that it adjusts the padding on the first and last node...with the Javascript so that I don't have to add actual classes to the <LI> items that will conflict with the existing script. I am having some problems and can't seem to find an example that is close enough to what I need done. Any help or links would be very much appreciated!! The current JavaScript is here:


<script type="text/javascript">
window.onload= function()
{
var mylist= document.getElementById("headerNav");
mylist.onmouseover= function(e)
{
e= window.event? event.srcElement: e.target;
if(e.nodeName== 'A')
{
var pa=e.parentNode;
pa.className= 'menuActive';
}
}

mylist.onmouseout= function(e)
{
e= window.event? event.srcElement: e.target;
if(e.nodeName== 'A')
{
var pa=e.parentNode;
pa.className= '';
}
}
}
</script>