RickStrahl / jquery-watch

A jQuery plug-in to watch CSS style and attribute changes and get notified when a change occurs
MIT License
133 stars 31 forks source link

README improvement #10

Closed bm2u closed 8 years ago

bm2u commented 8 years ago

Hey Rick, excellent work. Would you be so kind as to provide an example for observing childList (added, removed)? Thx in advance, bm2u

bm2u commented 8 years ago

Got it.

$list.watch({
        properties: 'prop_innerHTML',
        watchChildren: true,
        callback: function (data, i, mutations) {

            mutations.forEach(function(record) {
                if (record.type === 'childList' && record.removedNodes.length > 0) {
                    console.info('removed item');        
                } else if (record.addedNodes.length > 0) {
                    console.info('added item');
                }
            });
        }
    });
RickStrahl commented 8 years ago

Great - thanks for posting!