mituri

[JS] mutationObserver nice

Aug 19th, 2019
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. const target = document.querySelector('.search-box'),
  2. MutationObserver = window.MutationObserver || window.WebKitMutationObserver,
  3. searchBoxObserver = new MutationObserver(mutationHandler),
  4. config = { attributes: true, attributeOldValue: true, attributeFilter: ['class'] };
  5.  
  6. function mutationHandler (mutations) {
  7. mutations.forEach(function () {
  8. $('#search-dropdown').val('');
  9. });
  10. }
  11.  
  12. searchBoxObserver.observe(target, config);
Advertisement
Add Comment
Please, Sign In to add comment