Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Several years later, there is now officially a better solution. <a href="https://dom.spec.whatwg.org/#interface-mutationobserver" rel="noreferrer">DOM4 Mutation Observers</a> are the replacement for deprecated DOM3 mutation events. They are <a href="http://caniuse.com/#feat=mutationobserver" rel="noreferrer">currently implemented in modern browsers</a> as <code>MutationObserver</code> (or as the vendor-prefixed <code>WebKitMutationObserver</code> in old versions of Chrome):</p> <pre><code>MutationObserver = window.MutationObserver || window.WebKitMutationObserver; var observer = new MutationObserver(function(mutations, observer) { // fired when a mutation occurs console.log(mutations, observer); // ... }); // define what element should be observed by the observer // and what types of mutations trigger the callback observer.observe(document, { subtree: true, attributes: true //... }); </code></pre> <p>This example listens for DOM changes on <code>document</code> and its entire subtree, and it will fire on changes to element attributes as well as structural changes. The draft spec has a full list of valid <a href="https://dom.spec.whatwg.org/#interface-mutationobserver" rel="noreferrer">mutation listener properties</a>:</p> <blockquote> <p><strong>childList</strong></p> <ul> <li>Set to <code>true</code> if mutations to target's children are to be observed.</li> </ul> <p><strong>attributes</strong></p> <ul> <li>Set to <code>true</code> if mutations to target's attributes are to be observed.</li> </ul> <p><strong>characterData</strong></p> <ul> <li>Set to <code>true</code> if mutations to target's data are to be observed.</li> </ul> <p><strong>subtree</strong></p> <ul> <li>Set to <code>true</code> if mutations to not just target, but also target's descendants are to be observed.</li> </ul> <p><strong>attributeOldValue</strong></p> <ul> <li>Set to <code>true</code> if <code>attributes</code> is set to true and target's attribute value before the mutation needs to be recorded.</li> </ul> <p><strong>characterDataOldValue</strong></p> <ul> <li>Set to <code>true</code> if <code>characterData</code> is set to true and target's data before the mutation needs to be recorded.</li> </ul> <p><strong>attributeFilter</strong></p> <ul> <li>Set to a list of attribute local names (without namespace) if not all attribute mutations need to be observed.</li> </ul> </blockquote> <p>(This list is current as of April 2014; you may check the specification for any changes.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload