当图像实际出现在屏幕上时,如何让jQuery调用事件处理程序? [英] How can I get jQuery to call an event handler when an image actually appears on-screen?
问题描述
当我向下滚动并看到图片时,如何使用jQuery触发JavaScript函数的回调?我希望延迟加载某些图像,直到它们实际出现在屏幕上...理想情况下,我可以执行以下操作:
$('#img#')。look_on(){...
所以没有我们认为这个JQuery Event Plugin可以满足您的需要:
我创建了一个事件,当元素滚动到视口。
同样,LazyLoad插件似乎有一个视口选择器用于JQuqery: 这里 。
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.
这篇关于当图像实际出现在屏幕上时,如何让jQuery调用事件处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!