Create a jQuery special event for content changed

后端 未结 4 1055
面向向阳花
面向向阳花 2020-12-07 23:48

I\'m trying to create a jQuery special event that triggers when the content that is bound, changes. My method is checking the content with a setInterval and check if the con

4条回答
  •  [愿得一人]
    2020-12-08 00:19

    maybe you could try Mutation Observer

    Here are the code:

    mainArea = document.querySelector("#main_area");
    MutationObserver = window.MutationObserver;
    DocumentObserver = new MutationObserver(function() {
           //what you want to run
    });
    
    DocumentObserverConfig = {attributes: true, childList: true, characterData: true, subtree: true};
    
    DocumentObserver.observe(mainArea, DocumentObserverConfig);
    

提交回复
热议问题