By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,472 Members | 1,172 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,472 IT Pros & Developers. It's quick & easy.

Getting all elements that share the same class - possible?

P: n/a
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

--
To reply by e-mail remove the "waste bin".
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Martin Sammtleben wrote:
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:
<news:40**************@PointedEars.de>
--
To reply by e-mail remove the "waste bin".


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
Jul 23 '05 #2

P: n/a
In article <40**************@PointedEars.de>,
Thomas 'PointedEars' Lahn <Po*********@nurfuerspam.de> wrote:
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.


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

--
To reply by e-mail remove the "waste bin".
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.