Skip to content

Custom jQuery selector to detect elements currently visible on-screen

License

Notifications You must be signed in to change notification settings

jdbevan/onScreen

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

onScreen

onScreen is a jQuery plugin to detect whether an element is currently visible on-screen. It adds the :onScreen selector which you can use like so: $("span: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

Copyright 2011 Ben Pickles. See LICENSE for details.

About

Custom jQuery selector to detect elements currently visible on-screen

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%