zoukankan      html  css  js  c++  java
  • jquery Loading图片延迟加载特效

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>jquery图片延迟加载</title>
    <script src="js/jquery-1.6.js" type="text/javascript"></script>
    <script src="js/lyz.delayLoading.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    	$("img").delayLoading({
    		defaultImg: "images/loading.jpg",    // 预加载前显示的图片
    		errorImg: "",                        // 读取图片错误时替换图片(默认:与defaultImg一样)
    		imgSrcAttr: "originalSrc",           // 记录图片路径的属性(默认:originalSrc,页面img的src属性也要替换为originalSrc)
    		beforehand: 0,                       // 预先提前多少像素加载图片(默认:0)
    		event: "scroll",                     // 触发加载图片事件(默认:scroll)
    		duration: "normal",                  // 三种预定淡出(入)速度之一的字符串("slow", "normal", or "fast")或表示动画时长的毫秒数值(如:1000),默认:"normal"
    		container: window,                   // 对象加载的位置容器(默认:window)
    		success: function (imgObj) { },      // 加载图片成功后的回调函数(默认:不执行任何操作)
    		error: function (imgObj) { }         // 加载图片失败后的回调函数(默认:不执行任何操作)
    	});
    });
    </script>
    <style type="text/css">
    .box{ 1200px; margin:0 auto;}
    .box ul li { 245px; height:245px; float:left; margin:10px; border:1px solid #e6e6e6; list-style:none; }
    .box ul li img{ 100%; min-height:245px;}
    </style>
    </head>
    <body>
    	<div class="box">
    		<ul>
    	        <li><img originalsrc="images/1.jpg" /></li>
    	        <li><img originalsrc="images/2.jpg" /></li>
    	        <li><img originalsrc="images/3.jpg" /></li>
    	        <li><img originalsrc="images/4.jpg" /></li>
    	        <li><img originalsrc="images/5.jpg" /></li>
    	        <li><img originalsrc="images/6.jpg" /></li>
    	    </ul>
    	</div>
    </body>
    

      

  • 相关阅读:
    H53D旋转-遁地龙卷风
    Linux(CentOS 7)+ Nginx(1.10.2)+ Mysql(5.7.16)+ PHP(7.0.12)完整环境搭建
    CentOS 普通用户设置sudo权限
    CentOS 7 终端设置屏幕分辨率
    JavaScript 数组详解
    javascript 创建对象及对象原型链属性介绍
    Mac OS + Nginx + Mysql + PHP 本地环境搭建
    CocoaPods安装和使用教程
    Linux 下常用的压缩,解压方法
    启动 mysql 失败 Warning:The /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql'
  • 原文地址:https://www.cnblogs.com/adtuu/p/4670319.html
Copyright © 2011-2022 走看看