To move this old mutation event jQuery code
$('#container .class').on('DOMNodeInserted.mynamespace', 'input[type="number"]', function (e) {
...
$(this).closest('#container .class').off('DOMNodeInserted.mynamespace');
});
to MutationObserver, I have to add the observer to multiple elements at once:
var observer = new MutationObserver(function (mutations, observer) {
...
});
var config = {
subtree: true,
childList: true
};
$("#container .class").each(function () {
observer.observe(this, config);
});
But how can I similarly remove the observer from a single element at a time (after the first time the event/observer runs successfully) to retain the behaviour of the pre-MutationObserver version?