[whatwg] getElementsByClassName()

Simon Pieters zcorpan at hotmail.com
Fri Feb 3 16:20:12 PST 2006


Hi,

From: Michel Fortin <michel.fortin at michelf.com>
>I have a some markup like this:
>
>     <ul>
>         <li><a href="#tab1">Tab 1</a></li>
>         <li><a href="#tab2">Tab 2</a></li>
>     </ul>
>
>     <div id="tab1" class="pane">
>         ...
>     </div>
>
>     <div id="tab2" class="pane">
>         ...
>     </div>
>
>With the help of a style sheet, the script transforms this into some  sort 
>of tab view. It search for each div of class "pane". It looks  for links 
>pointing to each of these div elements and attach an event  to each so that 
>when you click on the link it shows the pane (and  hides other panes).

You could do this with the following CSS:

   .pane:not(:target) { display:none; }

Thus getElementsByClassName() is not needed for this use case.

Regards,
Simon Pieters





More information about the whatwg mailing list