Can jQuery selectors be used with DOM mutation observers?

后端 未结 4 1248
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 10:23

HTML5 includes a concept of \"mutation observers\" to monitor changes to the browser\'s DOM.

Your observer callback will be passed data which looks a lot like DOM tr

4条回答
  •  一生所求
    2020-12-04 10:36

    I know this is an old question but perhaps this can help others searching for alternative solutions. I recently learned about Mutation Observers and wanted to experiment with using them alongside jQuery. I came up with two possible approaches and turned them into plugins. The code is available here.

    The first approach (jquery.observeWithEvents.js) uses jQuery's trigger() function to trigger either an insertNode or removeNode event which can be bound to via jQuery's on() function. The second approach (jquery.observeWithCallbacks.js) uses traditional callback parameters. Please take a look at the README for examples and usage.

提交回复
热议问题