getElementsByTagName question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?cm9kY2hhcg==?=

    getElementsByTagName question

    hey all,
    is there a way to delete or remove and item from the results of
    getElementsByTa gName?

    thanks,
    rodchar
  • Anthony Jones

    #2
    Re: getElementsByTa gName question

    "rodchar" <rodchar@discus sions.microsoft .comwrote in message
    news:382C4C64-3F28-469C-874B-DB9B54785B1A@mi crosoft.com...
    hey all,
    is there a way to delete or remove and item from the results of
    getElementsByTa gName?
    >

    Its not entirely clear what you actually want to do.

    If you mean you want to take the list of items returned by
    getElementsByTa gName and remove an item from that list then:-

    no you can't do that directly. You can copy the list into an array skipping
    any that do not conform to come criteria:-

    function filterNodeSet(n odeSet, callback)
    {
    var resultSet = new Array()
    for (var i = 0, length = list.length; i < length; i++)
    if (callback(nodeS et[i])) resultSet.push( nodeSet[i])
    }


    var newSet = filterNodeSet(o ldSet, function(node) {
    return <boolean expression using node here>
    })


    If you mean can you delete from the DOM a node found via
    getElementsByTa gName then yes:-

    nodeSet[i].parentNode.rem oveChild(nodeSe t[i])



    --
    Anthony Jones - MVP ASP/ASP.NET


    Comment

    • =?Utf-8?B?cm9kY2hhcg==?=

      #3
      Re: getElementsByTa gName question

      thank you it was the 1st one but thank you for covering both,
      rod.

      "Anthony Jones" wrote:
      "rodchar" <rodchar@discus sions.microsoft .comwrote in message
      news:382C4C64-3F28-469C-874B-DB9B54785B1A@mi crosoft.com...
      hey all,
      is there a way to delete or remove and item from the results of
      getElementsByTa gName?
      >
      >
      Its not entirely clear what you actually want to do.
      >
      If you mean you want to take the list of items returned by
      getElementsByTa gName and remove an item from that list then:-
      >
      no you can't do that directly. You can copy the list into an array skipping
      any that do not conform to come criteria:-
      >
      function filterNodeSet(n odeSet, callback)
      {
      var resultSet = new Array()
      for (var i = 0, length = list.length; i < length; i++)
      if (callback(nodeS et[i])) resultSet.push( nodeSet[i])
      }
      >
      >
      var newSet = filterNodeSet(o ldSet, function(node) {
      return <boolean expression using node here>
      })
      >
      >
      If you mean can you delete from the DOM a node found via
      getElementsByTa gName then yes:-
      >
      nodeSet[i].parentNode.rem oveChild(nodeSe t[i])
      >
      >
      >
      --
      Anthony Jones - MVP ASP/ASP.NET
      >
      >
      >

      Comment

      Working...