npm.io
1.0.7 • Published 5 years ago

watchmydom

Licence
MIT
Version
1.0.7
Deps
0
Size
38 kB
Vulns
0
Weekly
0

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

  1. Add the library script into your page
<script src="watchmydom.min.js"></script>
  1. Initialize watchMyDom object in your custom script. You can use a class name, id or a tagName.
var watchIt = new watchMyDom("#div-id");
  1. Use watch() method to start watching.
watchIt.watch(function (result, info) {
	//Callback
});
  1. Use stop() method to stop watching.
watchIt.stop();

npm Installation

  1. Install the package

    npm i watchmydom
  2. 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