Getting all elements that share the same class - possible?

M

Martin Sammtleben

Hi everyone,

I have been using a script to toggle the visibility (via the "display"
property) of a specific ID hence a single elemnt on a page using
document.getElementById:


function ToggleIDvis() {
if (!document.getElementById) return false;

var targetIDvis = document.getElementById("hidden");

if (targetIDvis.style.display == "block") {
targetIDvis.style.display = "none";
} else {
targetIDvis.style.display = "block";
}
}



Now I would like to toggle the visibility of multiple elements on the
page and I'm wondering if there's a way to get those elements by a
certain class name.

Any hints are very much appreciated!

Cheers Martin
 
T

Thomas 'PointedEars' Lahn

Martin said:
Now I would like to toggle the visibility of multiple elements on the
page and I'm wondering if there's a way to get those elements by a
certain class name.

There is, but it is more efficient to manipulate the respective
CSS rule, if supported. Please search before you post:

To get replies by e-mail that are likely to come from communicative
people but from spambots, use the Reply-To header. If that does not
help, use spam filters.


PointedEars
 
M

Martin Sammtleben

Now I would like to toggle the visibility of multiple elements on the
page and I'm wondering if there's a way to get those elements by a
certain class name.

There is, but it is more efficient to manipulate the respective
CSS rule, if supported.[/QUOTE]

Following up on the issue I have managed to find what I needed to know
thanks to your post that pointed me into the right direction.

For anyone interested:

<http://developer.apple.com/internet/webcontent/styles.html>

also interesting:

<http://developer.apple.com/internet/webcontent/dom2ii.html>

Cheers Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top