Subscribing to the "childrenAdded" event in jQuery

Is there a way to subscribe to a wrapped set event that will fire when an item is added to it as a child?

+4
source share
1 answer

There is nothing standard (DOM or jQuery) that is widely supported. There were mutation events specified in the DOM2 Events specification, but they were burdensome to implement, were never widely implemented, and deprecated in the DOM3 Events specification .

You may be able to hack the internal domManip function in jQuery, which is used for most of these kinds of operations; but of course, this means that every jQuery release you have to hack again, and the internals can change so that your hack no longer works (and will only work if the caller used jQuery to add, even in code written for jQuery I knew that I was direct to the DOM when it was convenient). There the script in the answer taken on the AndreasAL question was found , but at the same time the mutation events were outdated, well, your mileage may change as browsers continue to update ...

+1
source

Source: https://habr.com/ru/post/1403055/


All Articles