简体   繁体   中英

How can I get jQuery to call an event handler when an image actually appears on-screen?

How can I use jQuery to trigger a callback of a JavaScript function when I scroll down and see a picture? I wish to delay loading certain images until they actually appear on-screen... Ideally, I'd be able to do something like:

$('#img#').look_on() { ...

So no images are loaded apart from those I have seen.

I think this JQuery Event Plugin does what you need:

Element 'in view' Event Plugin

I've created an event that will trigger when the element is scrolled in to the viewport.

also, the LazyLoad Plugin seems to have a "viewport" selector for JQuqery: Here .

这有点像我搜索的内容... http://www.appelsiini.net/projects/lazyload

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM