Find All Span Tags

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric Cota

    Find All Span Tags

    I have a page which has multiple span tags, I would like a javascript
    function that can look at each of these span tags for me. Depending
    on the what the user is doing there could be a different number of
    span tags so I don't want to hard code them.

    Thanks

    Eric
  • Lasse Reichstein Nielsen

    #2
    Re: Find All Span Tags

    cotae@nimo.com (Eric Cota) writes:
    [color=blue]
    > I have a page which has multiple span tags, I would like a javascript
    > function that can look at each of these span tags for me. Depending
    > on the what the user is doing there could be a different number of
    > span tags so I don't want to hard code them.[/color]

    var spans = document.getEle mentsByTagName( "span");
    for (var i=0;i<spans.len gth;i++) {
    ... spans[i] ...
    }

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Martin Honnen

      #3
      Re: Find All Span Tags



      Eric Cota wrote:[color=blue]
      > I have a page which has multiple span tags, I would like a javascript
      > function that can look at each of these span tags for me. Depending
      > on the what the user is doing there could be a different number of
      > span tags so I don't want to hard code them.
      >[/color]

      var spans;
      if (document.all) {
      spans = document.all.ta gs('span');
      }
      else if (document.getEl ementsByTagName ) {
      spans = document.getEle mentsByTagName( 'span');
      }
      if (spans) {
      // do something with it
      }



      --

      Martin Honnen


      Comment

      Working...