Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Custom jQuery selector to detect elements currently on-screen
JavaScript CSS
Branch: master
Failed to load latest commit information.
assets Update docs, better example.
LICENCE It's 2013. Add a little ditty about combining with the :visible selector.
jquery.onscreen.js Updated GitHub links.
jquery.onscreen.min.js Updated GitHub links.


onScreen is a jQuery plugin to detect whether an element is currently visible on-screen. It adds the :onScreen selector which is used to select only those elements that are currently within the bounds of the screen: $("span:onScreen"). It can also be combined with other selectors so, for example, to return only visible, on-screen elements use $("span:visible:onScreen").

$(function() {
  setInterval(function() {
    $("h2")                             // get all <h2>s
      .css("background-color", "")      // reset their background colours
      .filter(":onScreen")              // get only <h2>s on screen
        .css("background-color", "red") // give them a red background
  }, 1000)                              // repeat every second


Copyright 2011-2013 Ben Pickles. See LICENCE for details.

Something went wrong with that request. Please try again.