문제

I would like to know how I can listen to the DOM when a SPECIFIC element is added, and then act upon it.

After the DOM s loaded initially, there is a div(.myElement) that is loaded long afterwards:

<div class="container">.
   ...
   ...
   ...
   <div class="myElement"></div>
</div>

 $("div.container").bind("DOMNodeInserted",function(){
        alert("div.myElement has just been appended");
    });

Now the moment the element:

<div class="myElement"></div>

is added to the parent div(container), i want to run a function. How do i do that?

Thank you

도움이 되었습니까?

해결책

You can't. DOmNodeInserted has been removed and there's no alternative.

Solutions to provide a similar behavior are

  • pulling, ie testing with setInterval for additions. That would degrade performances.
  • changing the code inserting the element.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top