fj wrote:
I have no problem nevigate and neil down the element I want to manipulate.
What I want to do is set the css class of an item according to
window.location (URL). But it doesn't work.
I call this function in
<body onload="SelectMenuItem();" >
here is the function
function SelectMenuItem() {
...
//i is a variable I set before.
var nodes_LI = document.getElementById("TopNav").childNodes;
for (j=0; j<nodes_LI.length; j++) {
nodes_LI[j].firstChild.removeAttribute("class");
It seems to me that you're trying to remove the attribute class
specification. You are not trying to remove the attribute node value.
}
nodes_LI[i].firstChild.setAttribute("class", "highlighted");
Why not then just use DOM 2 HTML method to do this?
if(nodes_LI[i].firstChild.nodeType == 1)
{
nodes_LI[i].firstChild.className ="highlighted";
//http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-95362176
}
else
{
// code here
};
It's kinda difficult to offer you alternatives or guess better ones
since you have not provided any url nor a complete description of what
you were trying to do exactly.
DU
--
The site said to use Internet Explorer 5 or better... so I switched to
Firefox 1.0.4 :)