Obtaining the last inserted node.

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

    Obtaining the last inserted node.

    Hi.

    I would like to know how to obtain a reference to (or at least, element
    type of) the last node which was inserted into the document. I am using
    an event listener to listen for dom inserts, but I am not sure how to
    check if that last node was a script tag.

    Please could someone point me in the right direction?

    Many thanks, and Merry Christmas.

    Daz.

  • Martin Honnen

    #2
    Re: Obtaining the last inserted node.

    Daz wrote:
    I would like to know how to obtain a reference to (or at least, element
    type of) the last node which was inserted into the document. I am using
    an event listener to listen for dom inserts, but I am not sure how to
    check if that last node was a script tag.
    If that is the W3C DOM Level 2 DOMNodeInserted event e.g.

    document.addEve ntListener('DOM NodeInserted', function (evt) {
    alert(evt.targe t + ' inserted under parent ' + evt.relatedNode );
    }, false);

    then the evt.target tells you the inserted node and evt.relatedNode the
    parent node into which evt.target has been inserted. So you can check
    whether evt.target is an element node and if so, its
    tagName.toLower Case() is 'script'.


    --

    Martin Honnen

    Comment

    • Daz

      #3
      Re: Obtaining the last inserted node.


      Martin Honnen wrote:
      Daz wrote:
      >
      I would like to know how to obtain a reference to (or at least, element
      type of) the last node which was inserted into the document. I am using
      an event listener to listen for dom inserts, but I am not sure how to
      check if that last node was a script tag.
      >
      If that is the W3C DOM Level 2 DOMNodeInserted event e.g.
      >
      document.addEve ntListener('DOM NodeInserted', function (evt) {
      alert(evt.targe t + ' inserted under parent ' + evt.relatedNode );
      }, false);
      >
      then the evt.target tells you the inserted node and evt.relatedNode the
      parent node into which evt.target has been inserted. So you can check
      whether evt.target is an element node and if so, its
      tagName.toLower Case() is 'script'.
      >
      >
      --
      >
      Martin Honnen
      http://JavaScript.FAQTs.com/
      Fantastic!

      Thanks Martin. :)

      Comment

      Working...