jquery-watch
jquery-watch copied to clipboard
Watching element width not working
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?