How can I select several DIV-Objects using their ID

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Turner

    How can I select several DIV-Objects using their ID

    Hello.
    Okay, here's my problem:
    I got several DIV's and all start with the same ID="contentDiv " and at the end they got a number.
    For example, the php could generate following DIVs:
    contentDiv2
    contentDiv4
    contentDiv23
    contentDiv24
    I just want to set all of these DIVs to:
    div.style.displ ay = 'none';
    but I have no idea how I could efficiently select them.
    All my Ideas are way to complicated and cause a noticeable delay...
    getElementsByNa me isn't possible because DIVs do not have the "name"-tag...
    and I heard that getElementsByCl ass (/Name) doesn't work for IE...
    Does anyone of you got a professional solution for this problem?

    Thank you in advance.
    Chris
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    give the divs a class and use a cross-browser implementation of getElementsByCl assName() (ex.)

    Comment

    • Chris Turner

      #3
      Okay, this seems to be perfect for my needs.
      Thank you very much.
      Chris :)

      Comment

      Working...