OnScreen
Custom jQuery selector to detect elements currently on-screen
Install / Use
/learn @benpickles/OnScreenREADME
onScreen
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
Copyright 2011-2013 Ben Pickles. See LICENCE for details.
Related Skills
node-connect
340.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
340.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.2kCommit, push, and open a PR
