javascript - Best way to show new notifications -


i'm developing system there notification section icon have high light icon if new notification arrive. first solution wanted use domnodeinserted container div of notification pane. method deprecated. second option implement timer checks whether dom count increase , according highlight icon.

is there better way implement scenario using javascript.

that event deprecated in favor of mutation observers supported modern browsers. https://developer.mozilla.org/en-us/docs/web/api/mutationobserver

// select target node var target = document.queryselector('#some-id');  // create observer instance var observer = new mutationobserver(function(mutations) {   mutations.foreach(function(mutation) {     console.log(mutation.type);   });     });  // configuration of observer: var config = { attributes: true, childlist: true, characterdata: true };  // pass in target node, observer options observer.observe(target, config);  // later, can stop observing observer.disconnect(); 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -