[Javascript] Fw: hide other divs

Michael Borchers list at tridemail.de
Wed Apr 12 03:43:00 CDT 2006


>>>
the following function works fine in IE, not in FF.
I guess i worked a little bit dirty and FF is missing some kind of ID.

example div:
<div name="ordersDiv" id="ordersDiv" style="display:block">

function:
function hideOtherDivs(myDiv, mySubstring)
{
 var divElements = document.getElementsByTagName("div");

    for(i=0;i<divElements.length;i++)
 {
        divElementsId = divElements[i].getAttribute("id");
  
  if(divElementsId.substring(0,6) == mySubstring && divElementsId != myDiv)
  {
   divElements[i].style.display = "none";    
        }
    }
}

call:
javascript:hideOtherDivs('ordersDiv', 'orders');
<<<

ok, my suggestion wasn't that bad.
since i have a huge menu in my site there are lots of divs.
some of them have no properties, not name nor id.
IE doesn't care about this in the for(), but firefox
suddenly stops and breaks off.

i could create an own attribute i guess, but isn't there
some way to read out all div tags that only have ids
starting with a string like 'orders' ?!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20060412/0b24bc06/attachment.htm>


More information about the Javascript mailing list