jQuery: How can I detect if the html has changed within a given element?

后端 未结 1 1860
猫巷女王i
猫巷女王i 2020-12-31 15:54

In javascript, possibly using jQuery, how can I detect if the html content of a given element has changed?

I\'d like to be able to do somthing like:

         


        
1条回答
  •  滥情空心
    2020-12-31 16:16

    You can use the DOM Level 3 event DOMNodeInserted. Example:

    $('#myDiv').bind('DOMNodeInserted', function(e) {
        console.log('element: ', e.target, ' was inserted);
    });
    

    Demo: http://www.jsfiddle.net/vsgdZ/1/

    The event will fire whenever a new node was appended to the element on which you bind the handler.

    0 讨论(0)
提交回复
热议问题