【发布时间】:2019-08-17 00:58:10
【问题描述】:
在我的页面上很多地方我都使用了延迟加载效果。
插件网址http://www.appelsiini.net/projects/lazyload。
对于图像,我添加了“懒惰”类和
<input type="button" onclick="fn()" >
<script type="text/javascript">
$(function() {
fn()
$("img.lazy").lazyload();
});
function fn(){
var img = document.createElement('img');
img.setAttribute('data-original','bg.jpg')
img.className='lazy'
document.body.appendChild(img);
}
</script>
但在其他页面中,我用“lazy”类动态创建了图像,但lazyload 不起作用?如何解决?
【问题讨论】:
-
创建新图像后,对其应用延迟加载插件。
-
你如何创建动态图像?请添加代码
标签: javascript jquery