[thelist] DOM: Getting elements with class="foo"?

Christian Heilmann codepo8 at gmail.com
Wed Nov 23 12:26:16 CST 2005


> I've got a table with certain rows that have a class that point to
> display:none; I want to toggle visiblility with a link. Some rows have the
> class, others, none. How do I go about accessing the rows based on having
> the class name?
>
> After than I imagine it's just a matter of looping over them and change the
> class.

There is no getElementsByClassName in the specs but some developers
have done them already:

http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/

Be aware of the oddity of table rows when you show and hide them.
Don't use display block/none but display none and display:'' instead,
as otherwise some browsers would need block,whereas others need
table-row.

http://www.snook.ca/archives/000343.php

--
Chris Heilmann
Blog: http://www.wait-till-i.com
Writing: http://icant.co.uk/
Binaries: http://www.onlinetools.org/



More information about the thelist mailing list