getElementsByTagName('#comment') ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • X t l a n

    getElementsByTagName('#comment') ?

    Hi.

    I'm trying to get a reference to all comments on particular level of
    tree.

    lev.getElements ByTagName('#com ment') - this expression dosn't work at
    all
    lev.getElements ByTagName('!') - this works fine only for IE

    I prepared something like:
    for (_k=0, _l=lev.childNod es; _k<_l.length; _k++)
    if (lev.nodeName== '#comment' || lev.nodeName==' !') ...

    and works fine but I cannot see the reason, why script should search in
    all elements when getElementsByTa gName might be working quicker. Does
    anybody know, how to solve that?


    Cheers.

  • Martin Honnen

    #2
    Re: getElementsByTa gName('#comment ') ?


    X t l a n wrote:
    [color=blue]
    > I'm trying to get a reference to all comments on particular level of tree.
    >
    > lev.getElements ByTagName('#com ment') - this expression dosn't work at all
    > lev.getElements ByTagName('!') - this works fine only for IE[/color]

    getElementsByTa gName has that name as you can find element nodes that
    way and not comment nodes so the loop below is fine but simply check

    [color=blue]
    > for (_k=0, _l=lev.childNod es; _k<_l.length; _k++)[/color]

    if (lev.nodeType == 8)




    --

    Martin Honnen

    Comment

    • X t l a n

      #3
      Re: getElementsByTa gName('#comment ') ?

      > way and not comment nodes so the loop below is fine but simply check[color=blue][color=green]
      >> for (_k=0, _l=lev.childNod es; _k<_l.length; _k++)[/color]
      > if (lev.nodeType == 8)[/color]

      Under ie < 6 comment type is always 1 like for normal node that's why I
      check it the way like:
      if lev.nodeName==' #comment' ||lev.nodeName= ='!')

      Thx.

      Comment

      Working...