$('#someElement').watch({1}, {2}, {3});
DOMAttrModified or propertychange)
Change Paragraph Width/Height - (click again to reset)
Clicking on the link will animate the red box to 400px width and 200px height. The .watch() plugin will fire an event as the dimensions continue to change. The callback function looks for the width of the box to be larger then 200px and then changes the background color to green once it is greater then or equal to that. As well, if the height is greater then 100px then the background color will switch to blue.
Back to Article
jQuery(function($){
$(".demo span").watch('width,height', function(){
if(parseFloat($(this).width()) >= 150){
$(this).css({'background':'green'});
}
if(parseFloat($(this).height()) >= 200){
$(this).css({'background':'blue'});
}
});
$('.demo a').toggle(function(){
$('.demo span').animate({'width':'400px','height':'200px'}, 1000);
}, function(){
$('.demo span').css({'width':'50px','height':'50px','background':'red'});
});
});