watchmydom
A Javascript library to watch the DOM changes in a single callback
Demo
Click here to see the detailed demo.
Download
Minified script file has been added in the build
folder.
Installation/Usage
- Add the library script into your page
<script src="watchmydom.min.js"></script>
- Initialize
watchMyDom
object in your custom script. You can use a class name, id or a tagName.
var watchIt = new watchMyDom("#div-id");
- Use
watch()
method to start watching.
watchIt.watch(function (result, info) {
//Callback
});
- Use
stop()
method to stop watching.
watchIt.stop();
npm Installation
-
Install the package
npm i watchmydom
-
Use the module as shown below.
var watchmydom = require("watchmydom"); var domResults = new watchmydom(".dom-results");
Methods
Methods | Usage |
---|---|
watch() | Use this to start watching |
stop() | Use this to stop watching |
Callbacks
You can see the DOM updates/changes in the watch() calllback function.
Parameters | Usage |
---|---|
result | Sorted observations |
info | Complete observations |
License
MIT
Code
Saif