$.extend($.expr[':'], { inView: function(el) { var offset = $(el).offset(); return !( (offset.top > $(window).height() + $(document).scrollTop()) || (offset.top + $(el).height() < $(document).scrollTop()) || (offset.left > $(window).width() + $(document).scrollLeft()) || (offset.left + $(el).width() < $(document).scrollLeft()) ) } }); // usage $(#container :inView")