Determining if a HTML element has been added to the DOM dynamically

前端 未结 4 516
执笔经年
执笔经年 2020-12-05 00:24

Is there a way in Javascript or jQuery to find out when a HTML element has been added to the DOM dynamically, either through jQuery.append() or one of the nativ

4条回答
  •  無奈伤痛
    2020-12-05 01:00

    Why don't you try this? I dont remember the exact function I used but it's kinda similar than this...

    $(document).bind('DOMNodeInserted', function(event) {
          alert('inserted ' + event.target.nodeName + // new node
                ' in ' + event.relatedNode.nodeName); // parent
    });
    

    Also, I found some other options at this link:

    Event when element added to page

提交回复
热议问题