Код: Выделить всё
const targetElement = document.querySelector('div.serviceRequest');
// Create a MutationObserver
const observer = new MutationObserver(function(mutationsList) {
for (const mutation of mutationsList) {
if (mutation.type === 'childList') {
updateSubmenuWhenScrolling();
}
// TODO: If a certain element is no longer found, need to disconnect
// let loadingElement = document.querySelector('div.loading');
// if (!loadingElement) {
// observer.disconnect(); // ???
// }
}
});
// Configure the observer to watch for child list changes in the subtree
const config = { childList: true, subtree: true };
// Start observing the target element
if (targetElement) {
observer.observe(targetElement, config);
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... g-mutation
Мобильная версия