mituri

[JS] mutationObserver for class

Aug 14th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. var target = document.querySelector('.search-box');
  2. ​
  3. // create an observer instance
  4. var observer = new MutationObserver(function (mutations) {
  5. console.log(mutations);
  6. $('#search-dropdown').val('');
  7. ​
  8. });
  9. ​
  10. // configuration of the observer:
  11. var config = {
  12. attributes: true,
  13. childList: true,
  14. characterData: true,
  15. attributes: true,
  16. attributeOldValue: true,
  17. attributeFilter: ['class']
  18. };
  19. ​
  20. // pass in the target node, as well as the observer options
  21. observer.observe(target, config);
Add Comment
Please, Sign In to add comment