jquery-watch icon indicating copy to clipboard operation
jquery-watch copied to clipboard

Watching element width not working

Open NavCore opened this issue 7 years ago • 0 comments

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?

NavCore avatar Mar 22 '17 14:03 NavCore