我使用pinterest的API来固定我网站上的所有图像,通过我使用这个脚本的方式,它运行良好:
<script type="text/javascript" async defer data-pin-color="red"
data-pin-height="28" data-pin-hover="true"
src="//assets.pinterest.com/js/pinit.js"></script>
现在,所有标签"img"都固定正确,但当它们在后台时,我需要做同样的操作,例如:
<div style="background-image:url(blablabla);">
有些想法会很好!抱歉我的英语不好:)
您希望图像应该在代码中,而不是在屏幕不可见时加载图像吗?
如果是,那么您可以使用此LazyLoad jQuery库http://jquery-plugins.net/jquery-lazyload-any