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

Watching element width not working #16

Open NavCore opened 7 years ago

NavCore commented 7 years ago

I'm trying to watch element's width. Element's width is changing using CSS media querries.

My code looks like this:

    // some element to monitor
    var el = $("#content");

    // hook up the watcher
    el.watch({
        // specify CSS styles or attribute names to monitor
        properties: "width",

        // callback function when a change is detected
        callback: function(data, i) {
            var propChanged = data.props[i];
            var newValue = data.vals[i];

            var el = this;
            var el$ = $(this);

            // do what you need based on changes
            // or do your own checks

            console.log("changed"); // this was never fired
        }
    });

I'm resizing browser's window and my $("#content") element resizes as well, but I don't get console.log("changed") ?

What am I doing wrong?