Getting all elements that share the same class - possible?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Sammtleben

    Getting all elements that share the same class - possible?

    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.getEle mentById:


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

    var targetIDvis = document.getEle mentById("hidde n");

    if (targetIDvis.st yle.display == "block") {
    targetIDvis.sty le.display = "none";
    } else {
    targetIDvis.sty le.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".
  • Thomas 'PointedEars' Lahn

    #2
    Re: Getting all elements that share the same class - possible?

    Martin Sammtleben wrote:
    [color=blue]
    > 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.[/color]

    There is, but it is more efficient to manipulate the respective
    CSS rule, if supported. Please search before you post:
    <news:4095A319. 5050405@Pointed Ears.de>
    [color=blue]
    > --
    > To reply by e-mail remove the "waste bin".[/color]

    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

    Comment

    • Martin Sammtleben

      #3
      Re: Getting all elements that share the same class - possible?

      In article <40B89546.70700 00@PointedEars. de>,
      Thomas 'PointedEars' Lahn <PointedEars@nu rfuerspam.de> wrote:
      [color=blue][color=green]
      > > 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.[/color]
      >
      > There is, but it is more efficient to manipulate the respective
      > CSS rule, if supported.[/color]

      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".

      Comment

      Working...