
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>He Min Blog</title>
	<atom:link href="http://www.hemin.cn/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.hemin.cn/blog</link>
	<description>每一步细节注定你将来的命运。</description>
	<lastBuildDate>Wed, 28 Jul 2010 03:00:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script language="JavaScript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<link rel="stylesheet" href="http://www.hemin.cn/blog/wp-content/plugins/ajax-comment-vote/style.css" type="text/css" media="screen" />
<script language="JavaScript" type="text/javascript">
//<![CDATA[
var va = "您已经投过票了";
function acv_vote(id,option, m){
	if( m==null) m ='';	m = m + '';
	$('#acv_stat_'+m+id).html('正在处理...');
	var url="http://www.hemin.cn/blog/wp-admin/?acv_ajax=true&option="+option+"&ID="+id;
	$.get(url,function(d){
		d =d.split('|');var s='#acv_stat_'+m+d[0];
		var sele = '#cos_support-'+m+id,unsele = '#cos_unsupport-'+m+id,tpjs = 'javascript:alert(va)';
		$( s ).html( d[1] );$(s).fadeOut(400,function(){$(s).fadeIn();});
		if( d[2] == 1 ){ $(sele).html($(sele).html()*1+1); }
		if( d[2] == -1 ){ $(unsele).html($(unsele).html()*1+1); } 
		$('#vote4-'+id).attr('href',tpjs);$('#vote4-2'+id).attr('href',tpjs);
		$('#votea-'+id).attr('href',tpjs);$('#votea-2'+id).attr('href',tpjs);
	});
}

//]]>
</script>
	<script type='text/javascript' src='http://www.hemin.cn/blog/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
	<item>
		<title>php中session详解</title>
		<link>http://www.hemin.cn/blog/?p=1381</link>
		<comments>http://www.hemin.cn/blog/?p=1381#comments</comments>
		<pubDate>Wed, 28 Jul 2010 03:00:04 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[PHP/MySql]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[session]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1381</guid>
		<description><![CDATA[　在PHP开发中对比起Cookie，session 是存储在服务器端的会话，相对安全，并且不像 Cookie 那样有存储长度限制，本文简单介绍 session 的使用。 　　由于 Session 是以文本文件形式存储在服务器端的，所以不怕客户端修改 Session 内容。实际上在服务器端的 Session 文件，PHP 自动修改 session 文件的权限，只保留了系统读和写权限，而且不能通过 ftp 修改，所以安全得多。PHPChina 开源社区门户 　　对于 Cookie 来说，假设我们要验证用户是否登陆，就必须在 Cookie 中保存用户名和密码(可能是 md5 加密后字符串)，并在每次请求页面的时候进行验证。如果用户名和密码存储在数据库，每次都要执行一次数据库查询，给数据库造成多余的负担。因为我们并不能只做一次验证。为什么呢?因为客户端 Cookie 中的信息是有可能被修改的。假如你存储 $admin 变量来表示用户是否登陆，$admin 为 true 的时候表示登陆，为 false 的时候表示未登录，在第一次通过验证后将 $admin 等于 true 存储在 Cookie，下次就不用验证了，这样对么?错了，假如有人伪造一个值为 true 的 $admin 变量那不是就立即取的了管理权限么?非常的不安全。 　　而 Session 就不同了，Session 是存储在服务器端的，远程用户没办法修改 session 文件的内容，因此我们可以单纯存储一个 $admin 变量来判断是否登陆，首次验证通过后设置 $admin 值为 true，以后判断该值是否为 [...]]]></description>
			<content:encoded><![CDATA[<p>　在PHP开发中对比起Cookie，session 是存储在服务器端的会话，相对安全，并且不像 Cookie 那样有存储长度限制，本文简单介绍 session 的使用。<br />
　　由于 Session 是以文本文件形式存储在服务器端的，所以不怕客户端修改 Session 内容。实际上在服务器端的 Session 文件，PHP 自动修改 session 文件的权限，只保留了系统读和写权限，而且不能通过 ftp 修改，所以安全得多。PHPChina 开源社区门户<br />
<span id="more-1381"></span><br />
　　对于 Cookie 来说，假设我们要验证用户是否登陆，就必须在 Cookie 中保存用户名和密码(可能是 md5 加密后字符串)，并在每次请求页面的时候进行验证。如果用户名和密码存储在数据库，每次都要执行一次数据库查询，给数据库造成多余的负担。因为我们并不能只做一次验证。为什么呢?因为客户端 Cookie 中的信息是有可能被修改的。假如你存储 $admin 变量来表示用户是否登陆，$admin 为 true 的时候表示登陆，为 false 的时候表示未登录，在第一次通过验证后将 $admin 等于 true 存储在 Cookie，下次就不用验证了，这样对么?错了，假如有人伪造一个值为 true 的 $admin 变量那不是就立即取的了管理权限么?非常的不安全。<br />
　　而 Session 就不同了，Session 是存储在服务器端的，远程用户没办法修改 session 文件的内容，因此我们可以单纯存储一个 $admin 变量来判断是否登陆，首次验证通过后设置 $admin 值为 true，以后判断该值是否为 true，假如不是，转入登陆界面，这样就可以减少很多数据库操作了。而且可以减少每次为了验证 Cookie 而传递密码的不安全性了(session 验证只需要传递一次，假如你没有使用 SSL 安全协议的话)。即使密码进行了 md5 加密，也是很容易被截获的。<br />
　　当然使用 session 还有很多优点，比如控制容易，可以按照用户自定义存储等(存储于数据库)。我这里就不多说了。<br />
　　session 在 php.ini 是否需要设置呢?一般不需要的，因为并不是每个人都有修改 PHP.ini 的权限，默认 session 的存放路径是服务器的系统临时文件夹，我们可以自定义存放在自己的文件夹里，这个稍后我会介绍。<br />
　　开始介绍如何创建 session。非常简单，真的。<br />
　　启动 session 会话，并创建一个 $admin 变量：<br />
　　// 启动 session<br />
　　session_start();<br />
　　// 声明一个名为 admin 的变量，并赋空值。<br />
　　$_session["admin"] = null;　　?><br />
　　如果你使用了 Seesion，或者该 PHP 文件要调用 Session 变量，那么就必须在调用 Session 之前启动它，使用 session_start() 函数。其它都不需要你设置了，PHP 自动完成 session 文件的创建。<br />
　　执行完这个程序后，我们可以到系统临时文件夹找到这个 session 文件，一般文件名形如：sess_4c83638b3b0dbf65583181c2f89168ec，后面是 32 位编码后的随机字符串。用编辑器打开它，看一下它的内容：<br />
　　admin|N;<br />
　　一般该内容是这样的结构：<br />
　　变量名|类型:长度:值;<br />
　　并用分号隔开每个变量。有些是可以省略的，比如长度和类型。<br />
　　我们来看一下验证程序，假设数据库存储的是用户名和 md5 加密后的密码：<br />
　　// 表单提交后&#8230;<br />
　　$posts = $_POST;<br />
　　// 清除一些空白符号<br />
　　foreach ($posts as $key => $value)<br />
　　{<br />
　　$posts[$key] = trim($value);<br />
　　}<br />
　　$password = md5($posts["password"]);<br />
　　$username = $posts["username"];<br />
　　$query = &#8220;Select `username` FROM `user` Where `password` = &#8216;$password&#8217;&#8221;;<br />
　　// 取得查询结果<br />
　　$userInfo = $DB->getRow($query);<br />
　　if (!empty($userInfo))<br />
　　{<br />
　　if ($userInfo["username"] == $username)<br />
　　{<br />
　　// 当验证通过后，启动 session<br />
　　session_start();<br />
　　// 注册登陆成功的 admin 变量，并赋值 true<br />
　　$_session["admin"] = true;<br />
　　}<br />
　　else<br />
　　{<br />
　　die(&#8220;用户名密码错误&#8221;);<br />
　　}<br />
　　}<br />
　　else<br />
　　{<br />
　　die(&#8220;用户名密码错误&#8221;);<br />
　　}<br />
　　我们在需要用户验证的页面启动 session，判断是否登陆：<br />
　　// 防止全局变量造成安全隐患<br />
　　$admin = false;<br />
　　// 启动会话，这步必不可少<br />
　　session_start();<br />
　　// 判断是否登陆<br />
　　if (isset($_SESSION["admin"]) &#038;&#038; $_session["admin"] === true)<br />
　　{<br />
　　echo &#8220;您已经成功登陆&#8221;;<br />
　　}<br />
　　else<br />
　　{<br />
　　// 验证失败，将 $_session["admin"] 置为 false<br />
　　$_session["admin"] = false;<br />
　　die(&#8220;您无权访问&#8221;);<br />
　　}<br />
　　?><br />
　　是不是很简单呢?将 $_session 看成是存储在服务器端的数组即可，我们注册的每一个变量都是数组的键，跟使用数组没有什么分别。<br />
　　如果要登出系统怎么办?销毁 session 即可。<br />
　　session_start();<br />
　　// 这种方法是将原来注册的某个变量销毁<br />
　　unset($_session["admin"]);<br />
　　// 这种方法是销毁整个 session 文件<br />
　　session_destroy();　　><br />
　　Session 能否像 Cookie 那样设置生存周期呢?有了 Session 是否就完全抛弃 Cookie 呢?我想说，结合 Cookie 来使用 session 才是最方便的。<br />
　　Session 是如何来判断客户端用户的呢?它是通过 Session ID 来判断的，什么是 Session ID，就是那个 Session 文件的文件名，Session ID 是随机生成的，因此能保证唯一性和随机性，确保 Session 的安全。一般如果没有设置 Session 的生存周期，则 Session ID 存储在内存中，关闭浏览器后该 ID 自动注销，重新请求该页面后，重新注册一个 session ID。<br />
　　如果客户端没有禁用 Cookie，则 Cookie 在启动 Session 会话的时候扮演的是存储 Session ID 和 session 生存期的角色。<br />
　　我们来手动设置 session 的生存期：<br />
　　session_start();<br />
　　// 保存一天<br />
　　$lifeTime = 24 * 3600;<br />
　　setcookie(session_name(), session_id(), time() + $lifeTime, &#8220;/&#8221;);<br />
　　?><br />
　　其实 Session 还提供了一个函数 session_set_cookie_params(); 来设置 Session 的生存期的，该函数必须在 session_start() 函数调用之前调用：<br />
　　// 保存一天<br />
　　$lifeTime = 24 * 3600;<br />
　　session_set_cookie_params($lifeTime);<br />
　　session_start();<br />
　　$_session["admin"] = true;<br />
　　?><br />
　　如果客户端使用 IE 6.0 ， session_set_cookie_params(); 函数设置 Cookie 会有些问题，所以我们还是手动调用 setcookie 函数来创建 cookie。<br />
　　假设客户端禁用 Cookie 怎么办?没办法，所有生存周期都是浏览器进程了，只要关闭浏览器，再次请求页面又得重新注册 Session。那么怎么传递 Session ID 呢?通过 URL 或者通过隐藏表单来传递，PHP 会自动将 session ID 发送到 URL 上，URL 形如：http://www.openphp.cn /index.php?PHPSESSID=bba5b2a240a77e5b44cfa01d49cf9669，其中 URL 中的参数 PHPSESSID 就是 Session ID了，我们可以使用 $_GET 来获取该值，从而实现 session ID 页面间传递。<br />
　　// 保存一天<br />
　　$lifeTime = 24 * 3600;<br />
　　// 取得当前 session 名，默认为 PHPSESSID<br />
　　$sessionName = session_name();<br />
　　// 取得 session ID<br />
　　$sessionID = $_GET[$sessionName];<br />
　　// 使用 session_id() 设置获得的 session ID<br />
　　session_id($sessionID);<br />
　　session_set_cookie_params($lifeTime);<br />
　　session_start();<br />
　　$_session["admin"] = true;<br />
　　?><br />
　　对于虚拟主机来说，如果所有用户的 Session 都保存在系统临时文件夹里，将给维护造成困难，而且降低了安全性，我们可以手动设置 Session 文件的保存路径，session_save_path()就提供了这样一个功能。我们可以将 session 存放目录指向一个不能通过 Web 方式访问的文件夹，当然，该文件夹必须具备可读写属性。<br />
　　// 设置一个存放目录<br />
　　$savePath = &#8220;./session_save_dir/&#8221;;<br />
　　// 保存一天<br />
　　$lifeTime = 24 * 3600;<br />
　　session_save_path($savePath);<br />
　　session_set_cookie_params($lifeTime);<br />
　　session_start();<br />
　　$_session["admin"] = true;<br />
　　?><br />
　　同 session_set_cookie_params(); 函数一样，session_save_path() 函数也必须在 session_start() 函数调用之前调用。<br />
　　我们还可以将数组，对象存储在 session 中。操作数组和操作一般变量没有什么区别，而保存对象的话，PHP 会自动对对象进行序列化(也叫串行化)，然后保存于 session 中。下面例子说明了这一点：<br />
　　class person<br />
　　{<br />
　　var $age;<br />
　　function output() {<br />
　　echo $this->age;<br />
　　}<br />
　　function setAge($age) {<br />
　　$this->age = $age;<br />
　　}<br />
　　}<br />
　　?><br />
　　setage.PHP<br />
　　session_start();<br />
　　require_once &#8220;person.PHP&#8221;;<br />
　　$person = new person();<br />
　　$person->setAge(21);<br />
　　$_session['person'] = $person;<br />
　　echo &#8220;check here to output age&#8221;;<br />
　　?><br />
　　output.PHP<br />
　　// 设置回调函数，确保重新构建对象。<br />
　　ini_set(&#8216;unserialize_callback_func&#8217;, &#8216;mycallback&#8217;);<br />
　　function mycallback($classname) {<br />
　　$classname . &#8220;.PHP&#8221;;<br />
　　}<br />
　　session_start();<br />
　　$person = $_session["person"];<br />
　　// 输出 21<br />
　　$person->output();<br />
　　?><br />
　　当我们执行 setage.php 文件的时候，调用了 setage() 方法，设置了年龄为 21，并将该状态序列化后保存在 session 中(PHP 将自动完成这一转换)，当转到 output.php 后，要输出这个值，就必须反序列化刚才保存的对象，又因为在解序列化的时候需要实例化一个未定义类，所以我们定义了以后回调函数，自动包含 person.PHP 这个类文件，因此对象被重构，并取得当前 age 的值为 21，然后调用 output() 方法输出该值。</p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=1191" title="PHP程序常见漏洞攻击分析">PHP程序常见漏洞攻击分析</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1167" title="40条优化php代码的小实例">40条优化php代码的小实例</a> (2)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1381</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>一些AS3中常用到的公式</title>
		<link>http://www.hemin.cn/blog/?p=1376</link>
		<comments>http://www.hemin.cn/blog/?p=1376#comments</comments>
		<pubDate>Tue, 27 Jul 2010 09:38:17 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[AS3/Flex]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[公式]]></category>
		<category><![CDATA[常用]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1376</guid>
		<description><![CDATA[基本三角函数的计算： 角的正弦值 = 对边 / 斜边 角的余弦值 = 邻边 / 斜边 角的正切值 = 对边 / 邻边 角度制与弧度制的相互转换： 弧度 = 角度 * Math.PI / 180 角度 = 弧度 * 180 / Math.PI 计算两点间距离： dx = x2 – x1; dy = y2 – y1; dist = Math.sqrt(dx*dx + dy*dy); 缓动公式: sprite.x += (targetX – sprite.x) * easing;//easing为缓动系数变量 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>基本三角函数的计算：</strong><br />
角的正弦值 = 对边 / 斜边<br />
角的余弦值 = 邻边 / 斜边<br />
角的正切值 = 对边 / 邻边</p>
<p><strong>角度制与弧度制的相互转换：</strong><br />
弧度 = 角度 * Math.PI / 180<br />
角度 = 弧度 * 180 / Math.PI<br />
<span id="more-1376"></span><br />
计算两点间距离：<br />
dx = x2 – x1;<br />
dy = y2 – y1;<br />
dist = Math.sqrt(dx*dx + dy*dy);</p>
<p><strong>缓动公式:</strong><br />
sprite.x += (targetX – sprite.x) * easing;//easing为缓动系数变量<br />
sprite.y += (targetY – sprite.y) * easing;</p>
<p><strong>弹性公式:</strong><br />
vx += (targetX – sprite.x) * spring;//spring为弹性系数<br />
vy += (targetY – sprite.y) * spring;<br />
sprite.x += (vx *= friction);//friction为摩擦力<br />
sprite.y += (vy *= friction);</p>
<p><strong>偏移弹性公式:</strong><br />
var dx:Number = sprite.x – fixedX;<br />
var dy:Number = sprite.y – fixedY;<br />
var angle:Number = Math.atan2(dy, dx);<br />
var targetX:Number = fixedX + Math.cos(angle) * springLength;<br />
var targetY:Number = fixedX + Math.sin(angle) * springLength;</p>
<p><strong>向鼠标旋转(或向某点旋转)</strong><br />
dx = mouseX – sprite.x;<br />
dy = mouseY – sprite.y;<br />
sprite.rotation = Math.atan2(dy, dx) * 180 / Math.PI;</p>
<p><strong>波形运动:</strong><br />
public function onEnterFrame1(event:Event):void {<br />
ball.y=centerScale+Math.sin(angle)*range;<br />
angle+=speed;<br />
}</p>
<p><strong>心跳:</strong><br />
public function onEnterFrame1(event:Event):void {<br />
ball.scaleX=centerScale+Math.sin(angle)*range;<br />
ball.scaleY=centerScale+Math.sin(angle)*range;<br />
angle+=speed;<br />
}</p>
<p><strong>圆心旋转:</strong><br />
public function onEnterFrame(event:Event):void {<br />
ball.x=centerX+Math.cos(angle)*radius;<br />
ball.y=centerY+Math.sin(angle)*radius;<br />
angle+=speed;<br />
}</p>
<p><strong>椭圆旋转:</strong><br />
public function onEnterFrame(event:Event):void {<br />
ball.x=centerX+Math.cos(angle)*radiusX;<br />
ball.y=centerY+Math.sin(angle)*radiusY;<br />
angle+=speed;<br />
}</p>
<p><strong>颜色运算得到透明值:</strong><br />
var t:uint=0×77ff8877<br />
var s:uint=0xff000000<br />
var h:uint=t&#038;s<br />
var m:uint=h>>>24<br />
trace(m)</p>
<p><strong>转换为十进制:</strong><br />
trace(hexValue);<br />
<strong>十进制转换为十六进制:</strong><br />
decimalValue.toString(16)</p>
<p><strong>颜色提取:</strong><br />
red = color24 >> 16;<br />
green = color24 >> 8 &#038; 0xFF;<br />
blue = color24 &#038; 0xFF;<br />
alpha = color32 >> 24;<br />
red = color32 >> 16 &#038; 0xFF;<br />
green = color32 >> 8 &#038; 0xFF;<br />
blue = color232 &#038; 0xFF;</p>
<p><strong>按位计算得到颜色值:</strong><br />
color24 = red << 16 | green << 8 | blue;<br />
color32 = alpha << 24 | red << 16 | green << 8 | blue;</p>
<p><strong>过控制点的曲线:</strong><br />
// xt, yt是你想要让曲线通过的那一点<br />
// x0, y0 和x2, y2 是曲线的终点<br />
//PS.发现很多人转帖都是直接复制粘贴，也不翻译一下<br />
xt * 2 – (x0 + x2) / 2;<br />
y1 = yt * 2 – (y0 + y2) / 2;<br />
moveTo(x0, y0);<br />
curveTo(x1, y1, x2, y2);</p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=860" title="WordPress常用PHP调用代码">WordPress常用PHP调用代码</a> (3)</li><li><a href="http://www.hemin.cn/blog/?p=680" title="最常用的十个javascript自定义函数">最常用的十个javascript自定义函数</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1376</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>各种html+CSS实例效果 更新为2010.7.27</title>
		<link>http://www.hemin.cn/blog/?p=339</link>
		<comments>http://www.hemin.cn/blog/?p=339#comments</comments>
		<pubDate>Tue, 27 Jul 2010 08:05:57 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[(x)Html/Css]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[实例]]></category>
		<category><![CDATA[收藏]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=339</guid>
		<description><![CDATA[新增实例：CSS3 QQ企鹅 这里收集和原创各种html+CSS实例效果。（为了工作需要和学习得更多） 1、鼠标滑过改变文字: &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=gb2312&#34; /&#62; &#60;title&#62;鼠标经过变换文字(www.hemin.cn)&#60;/title&#62; &#60;style&#62; #Menu{ width:500px; margin:50px auto; border:1px solid #CCC; overflow:hidden; } #Menu ul{ margin:0;padding:0;list-style:none;} #Menu li{ width:100px; height:22px; line-height:22px; float:left; overflow:hidden; text-align:center; } #Menu a{ width:100px;float:left;overflow:hidden;} #Menu span{display:block;margin-top:-22px;} #Menu a:hover{padding-top:22px;} &#60;/style&#62; &#60;/head&#62; &#60;body&#62; &#60;ul id=&#34;Menu&#34;&#62; [...]]]></description>
			<content:encoded><![CDATA[<div style="font-size:14px;text-decoration:underline;">新增实例：<span style="color:#F00">CSS3 QQ企鹅</span></div>
<p>这里收集和原创各种html+CSS实例效果。（为了工作需要和学习得更多）</p>
<p><strong>1、鼠标滑过改变文字:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_YmiuR9">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;鼠标经过变换文字(www.hemin.cn)&lt;/title&gt;
&lt;style&gt;
#Menu{
	width:500px;
	margin:50px auto;
	border:1px solid #CCC;
	overflow:hidden;
	}
#Menu ul{ margin:0;padding:0;list-style:none;}
#Menu li{
	width:100px;
	height:22px;
	line-height:22px;
	float:left;
	overflow:hidden;
	text-align:center;
	}
#Menu a{ width:100px;float:left;overflow:hidden;}
#Menu span{display:block;margin-top:-22px;}
#Menu a:hover{padding-top:22px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;ul id=&quot;Menu&quot;&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;HOME&lt;/span&gt;首页&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;NEWS&lt;/span&gt;新闻&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;ABOUT&lt;/span&gt;关于&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;CONTACT&lt;/span&gt;联系&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;照片&lt;/span&gt;PHOTO&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_YmiuR9');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_YmiuR9');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_YmiuR9','runcode_YmiuR9');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><span id="more-339"></span><br />
<strong>2、边框为阴影效果:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_RP393_">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;边框为阴影效果(www.hemin.cn)&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
div {border-width: 1px; border-style: solid; padding: 1px;}
.a {background-color: #F3F3F3; border-color: #FBFBFB;}
.b {background-color: #D8D8D8; border-color: #E8E8E8;}
.c {background-color: #FFF; border-color: #BBB; height: 100px;color：#ff0000;}
.middle-demo-4{
width:300px;
border:#FF0000 1px solid;
height: 300px;
position:absolute;
}
.middle-demo-4 div{
border:#009900 1px solid;
height:20px;
width:300px;
position:absolute;
margin-top:-10px;
top:50%;
left:0;
}
.middle-demo-4 div div{
border:#330066  1px solid;
height:20px;
width:300px;
margin-top:-12px;
margin-left:-2px;
position:relative;
top: 50%;
left:0;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;a&quot;&gt;
  &lt;div class=&quot;b&quot;&gt;
    &lt;div class=&quot;c&quot;&gt;边框为阴影效果&lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;middle-demo-4&quot;&gt;
	&lt;div&gt;
		&lt;div&gt;让内容垂直居中&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_RP393_');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_RP393_');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_RP393_','runcode_RP393_');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>3、1个像素缺口:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_j6SjvF">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;title&gt;google analytics buttons(www.hemin.cn)&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
/* default stuff */
body {
	padding:20px;
	font-family:arial;
	text-align:center;
}
p, li {
	font-size: 12px;
	line-height:18px;
}
h3 {
	margin-bottom:6px;
}
.examplesGoHere {
	text-align:left;
	margin:0 auto;
}
.letsGiveItAFixedWidthOf200Pixels {
	width:200px;
}
ul {
	list-style:none;
	margin-left:0;
	padding-left:0;
	margin-top:0;
}
ul li {
	margin-bottom:8px;
	margin-left:0;
	padding-left:0;
}
/* notched effect for links in the unordered list */
.notchedListItems a {
	display:block;
	border: solid #666;
	border-width: 0 1px;
	text-decoration: none;
	outline:none;
	color: #000;
	background: #e4e4e4;
}
.notchedListItems a b {
	display: block;
	position:relative;
	top: -1px;
	left: 0;
	border:solid #666;
	border-width:1px 0 0;
	font-weight:normal;
}
.notchedListItems a b b {
	border-width:0 0 1px;
	top: 2px;
	padding:1px 6px;
}
.notchedListItems a:hover, .notchedListItems a:hover b {
	background:#666;
	color:white;
}
.feature {
	border:solid #647aae;
	border-width:0 1px;
	background:#b0c0e6;
}
.feature div {
	position:relative;
	top: -1px;
	left: 0;
	border:solid #647aae;
	border-width:1px 0 0;
}
.feature div div {
	top: 2px;
	border-width:0 0 1px;
	padding: 0px 6px;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;examplesGoHere letsGiveItAFixedWidthOf200Pixels&quot;&gt;
	&lt;h3&gt;A list&lt;/h3&gt;
	&lt;ul class=&quot;notchedListItems&quot;&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;b&gt;&lt;b&gt;About&lt;/b&gt;&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;b&gt;&lt;b&gt;Contact&lt;/b&gt;&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;b&gt;&lt;b&gt;Cssrain&lt;/b&gt;&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;h3&gt;A div&lt;/h3&gt;
	&lt;div class=&quot;feature&quot;&gt;
		&lt;div&gt;
			&lt;div&gt;
				&lt;p&gt;This is an example of the notched corners as applied to a div container.&lt;/p&gt;
				&lt;p&gt;This is an example of the notched corners as applied to a div container.&lt;/p&gt;
				&lt;p&gt;This is an example of the notched corners as applied to a div container.&lt;/p&gt;
			&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;
	&lt;ul class=&quot;notchedListItems&quot;&gt;
		&lt;li&gt;&lt;a href=&quot;http://www.hemin.cn&quot;&gt;&lt;b&gt;&lt;b&gt;hemin.cn&lt;/b&gt;&lt;/b&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
&lt;!-- end .examplesGoHere --&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_j6SjvF');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_j6SjvF');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_j6SjvF','runcode_j6SjvF');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>4、星级评分:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_LWgAIY">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
	&lt;title&gt;CSS: Star Rating Redux(www.hemin.cn)&lt;/title&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
	&lt;link href=&quot;http://www.hemin.cn/demo/xjpf/star_rating.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;all&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;h1&gt;CSS: Star Rating Redux&lt;/h1&gt;
	&lt;ul class=&quot;star-rating&quot;&gt;
		&lt;li class=&quot;current-rating&quot; style=&quot;width:60%;&quot;&gt;Currently 3/5 Stars.&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;1 star out of 5&quot; class=&quot;one-star&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;2 stars out of 5&quot; class=&quot;two-stars&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;3 stars out of 5&quot; class=&quot;three-stars&quot;&gt;3&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;4 stars out of 5&quot; class=&quot;four-stars&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;5 stars out of 5&quot; class=&quot;five-stars&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;h1&gt;CSS: Star Rating Redux inline&lt;/h1&gt;
	Rate this:
	&lt;span class=&quot;inline-rating&quot;&gt;
	&lt;ul class=&quot;star-rating small-star&quot;&gt;
		&lt;li class=&quot;current-rating&quot; style=&quot;width:30%;&quot;&gt;Currently 1.5/5 Stars.&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;1 star out of 5&quot; class=&quot;one-star&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;2 stars out of 5&quot; class=&quot;two-stars&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;3 stars out of 5&quot; class=&quot;three-stars&quot;&gt;3&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;4 stars out of 5&quot; class=&quot;four-stars&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;5 stars out of 5&quot; class=&quot;five-stars&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;&lt;/span&gt;
	And This:
	&lt;span class=&quot;inline-rating&quot;&gt;
	&lt;ul class=&quot;star-rating small-star&quot;&gt;
		&lt;li class=&quot;current-rating&quot; style=&quot;width:80%;&quot;&gt;Currently 4/5 Stars.&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;1 star out of 5&quot; class=&quot;one-star&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;2 stars out of 5&quot; class=&quot;two-stars&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;3 stars out of 5&quot; class=&quot;three-stars&quot;&gt;3&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;4 stars out of 5&quot; class=&quot;four-stars&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;5 stars out of 5&quot; class=&quot;five-stars&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/span&gt;
	&lt;h1&gt;Let's make it smaller&lt;/h1&gt;
	&lt;ul class=&quot;star-rating small-star&quot;&gt;
		&lt;li class=&quot;current-rating&quot; style=&quot;width:50%&quot;&gt;Currently 2.5/5 Stars.&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;1 star out of 5&quot; class=&quot;one-star&quot;&gt;1&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;2 stars out of 5&quot; class=&quot;two-stars&quot;&gt;2&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;3 stars out of 5&quot; class=&quot;three-stars&quot;&gt;3&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;4 stars out of 5&quot; class=&quot;four-stars&quot;&gt;4&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot; title=&quot;5 stars out of 5&quot; class=&quot;five-stars&quot;&gt;5&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_LWgAIY');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_LWgAIY');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_LWgAIY','runcode_LWgAIY');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>5、纯css文本渐变:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_jMpVyQ">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gbk&quot; /&gt;
&lt;title&gt;Css Trick - Pure Css Text Gradients(www.hemin.cn)&lt;/title&gt;
&lt;/meta&gt;
&lt;style&gt;
body {
	margin:0;
	padding:2em 4em;
	background:#fff;
	font:90% Arial, Helvetica, sans-serif;
	color:#555;
	line-height:180%;
}
h1 {
	font-size:300%;
	line-height:1em;
	color:#8bb544;
	font-weight:bold;
	text-transform:uppercase;
	letter-spacing:-.05em;
	position:relative;
}
h2 {
	font-size:260%;
	color:#0079b6;
	font-weight:bold;
	letter-spacing:-.05em;
	position:relative;
	margin:.6em 0;
	padding-top:1px; /* use top padding to adjust the start of the gradient  */
	width:100%;
}
h3 {
	font-size:240%;
	color:#7365a0;
	font-weight:bold;
	text-transform:uppercase;
	letter-spacing:-.05em;
	padding-top:3px;
	position:relative;
	margin:.6em 0;
	width:100%;
}
h4 {
	font-size:220%;
	color:#dc5b24;
	font-weight:normal;
	letter-spacing:-.05em;
	position:relative;
	margin:.6em 0;
	padding-top:1px;
	width:100%;
}
h1 span, h2 span, h3 span, h4 span{
	position:absolute;
	display:block;
	top:0;
	left:0;
	height:100%;
	width:100%;
	background:url(http://www.hemin.cn/demo/jianbian/gradient_1.png) repeat-x;
}
h1 span, h3 span{background:url(http://www.hemin.cn/demo/jianbian/gradient_2.png) repeat-x;}
* html h1 span, * html h3 span{
	background-color:#fff;
	back\ground-color:transparent;
	background-image: url(none.gif);
	filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=&quot;http://www.hemin.cn/demo/jianbian/gradient_2.png&quot;, sizingMethod=&quot;scale&quot;);
}
* html h2 span, * html h4 span{
	background-color:#fff;
	back\ground-color:transparent;
	background-image: url(none.gif);
	filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=&quot;http://www.hemin.cn/demo/jianbian/gradient_1.png&quot;, sizingMethod=&quot;scale&quot;);
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;纯净的CSS渐变文本&lt;span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;h2&gt;CSSRAIN DEMO&lt;span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h4&gt;国外收集过来的.&lt;span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;h5&gt;IE6.7,FF2通过.&lt;span&gt;&lt;/span&gt;&lt;/h5&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_jMpVyQ');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_jMpVyQ');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_jMpVyQ','runcode_jMpVyQ');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>6、隔行变色:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_BKHH6c">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;隔行变色&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
.list ul{position:relative;background:url(http://www.hemin.cn/Photo/list.gif) repeat 0 0;width:400px;}
.list ul li{height:32px;line-height:32px;}
.list ul li em{position:absolute;right:0px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;list&quot;&gt;
	&lt;h3&gt;这是隔行变色啊..&lt;/h3&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href=&quot;&quot; alt=&quot;&quot;&gt;这是隔行变色啊...&lt;/a&gt;&lt;em&gt;(2009-8-20)&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;&quot; alt=&quot;&quot;&gt;这是隔行变色啊...&lt;/a&gt;&lt;em&gt;(2009-8-20)&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;&quot; alt=&quot;&quot;&gt;这是隔行变色啊...&lt;/a&gt;&lt;em&gt;(2009-8-20)&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;&quot; alt=&quot;&quot;&gt;这是隔行变色啊...&lt;/a&gt;&lt;em&gt;(2009-8-20)&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;&quot; alt=&quot;&quot;&gt;这是隔行变色啊...&lt;/a&gt;&lt;em&gt;(2009-8-20)&lt;/em&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_BKHH6c');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_BKHH6c');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_BKHH6c','runcode_BKHH6c');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>7、鼠标经过文本时提示的信息:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_gPvSm9">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt;鼠标经过文本时提示的信息(www.hemin.cn)&lt;/title&gt;
&lt;meta name=&quot;generator&quot; content=&quot;editplus&quot; /&gt;
&lt;meta name=&quot;author&quot; content=&quot;&quot; /&gt;
&lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;
&lt;style type=&quot;text/css&quot;&gt;
/*Tooltips*/
.tooltips {
	position:relative; /*这个是关键*/
	z-index:2;
}
.tooltips:hover {
	z-index:3;
	background:none; /*没有这个在IE中不可用*/
}
.tooltips span {
	display: none;
}
.tooltips:hover span { /*span 标签仅在 :hover 状态时显示*/
	display:block;
	position:absolute;
	top:21px;
	left:9px;
	width:15em;
	border:1px solid black;
	background-color:#ccFFFF;
	padding: 3px;
	color:black;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;a class=&quot;tooltips&quot; href=&quot;#tooltips&quot;&gt;这就是Tooltips&lt;span&gt;正是你见到的，这些附加的说明文字是在鼠标经过的时候显示。&lt;/span&gt;&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_gPvSm9');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_gPvSm9');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_gPvSm9','runcode_gPvSm9');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>8、三级级联菜单(IE6不支持):</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_EDvvg4">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;meta name=&quot;author&quot; content=&quot;Chomo&quot; /&gt;
&lt;title&gt;三级级联菜单&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
* { margin:0; padding:0; list-style:none;}
.c_subNav { width:150px; }
.c_subNav a { text-decoration:none; color:#333;}
.c_subNav a:hover { color:#f60;}
.c_subNav ul ul { position:absolute; display:none; right:-150px; top:-1px;}
.c_subNav li { border-bottom:1px solid #ccc; position:relative; _position:static; float:left; width:100%;}
.c_subNav a.li { position:relative;}
.c_subNav li .option { display:block; line-height:15px; padding:5px 5px 5px 25px; background:no-repeat 5px 4px; cursor:pointer; font:12px Verdana; zoom:1; background:url(http://www.14px.com/wp-content/uploads/2009/05/ico.gif) no-repeat;}
.c_subNav li .option:hover { color:#f60; background-color:#ffa;}
.c_subNav li .option span { display:block; padding-right:15px; background:url(http://www.14px.com/wp-content/uploads/2009/05/ico.gif) no-repeat right 0;}
.c_subNav li .option:hover span { background-position:right -15px;}
.c_subNav .li:hover { z-index:2; background:transparent;}
.c_subNav .li:hover ul { display:block;}
.c_subNav .li:hover ul ul { display:none;}
.c_subNav .li:hover ul { border:1px solid #ccc; border-width:1px 2px 2px 1px; width:150px; background:#fff; padding:1px;}
.c_subNav .li:hover li { border-bottom:none;}
.c_subNav .li:hover li .option { padding:2px 5px; background:transparent;}
.c_subNav .li:hover li .option:hover { background:#0096ff; color:#fff;}
.c_subNav .li:hover li .option:hover span { background-position:right -30px;}
.c_subNav .li:hover .li:hover ul { display:block; left:145px; top:-2px;}
.c_subNav .charges .option { background-position:4px -45px;}
.c_subNav .biz .option { background-position:4px -70px;}
.c_subNav .change .option { background-position:4px -95px;}
.c_subNav .score .option { background-position:4px -120px;}
.c_subNav .server .option { background-position:4px -145px;}
.c_subNav .edit .option { background-position:4px -170px;}
.c_subNav .sms .option { background-position:4px -195px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;c_subNav&quot;&gt;
	&lt;ul&gt;
		&lt;li class=&quot;li charges&quot;&gt;
			&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;话费服务&lt;/span&gt;&lt;/a&gt;
			&lt;ul&gt;
				&lt;li class=&quot;li&quot;&gt;
					&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;话费查询&lt;/span&gt;&lt;/a&gt;
					&lt;ul&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;实时话费查询&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;话费余额查询&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;月账单查询&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;月详单查询&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;缴费历史查询&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;资费优选推荐&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;
					&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;定制话费信息&lt;/span&gt;&lt;/a&gt;
					&lt;ul&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;定制短信账单&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;话费余额短信提醒&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;定制Email账单&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;
					&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;网上交费&lt;/span&gt;&lt;/a&gt;
					&lt;ul&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;网上缴费&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;充值卡缴费&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;li biz&quot;&gt;
			&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;业务办理&lt;/span&gt;&lt;/a&gt;
			&lt;ul&gt;
				&lt;li class=&quot;li&quot;&gt;
					&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;日常业务办理&lt;/span&gt;&lt;/a&gt;
					&lt;ul&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;来电显示&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;呼叫等待&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;呼叫转移&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;三方通话&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;来电提醒&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;呼叫保持&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;呼叫转移设置&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;主叫隐藏&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;彩铃&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;国内漫游&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;短信回执&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;12580综合信息&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;关爱一线通&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;
					&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;数据业务&lt;/span&gt;&lt;/a&gt;
					&lt;ul&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;手机上网&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;GPRS&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;飞信&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;手机报&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;无线音乐俱乐部&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;手机邮箱&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;号簿管家&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;WLAN业务&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;彩乐短信&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;
					&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;手机报停/报开&lt;/span&gt;&lt;/a&gt;
					&lt;ul&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;手机报停&lt;/a&gt;&lt;/li&gt;
						&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;手机复机&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;
					&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;梦网查询与退订&lt;/a&gt;
				&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;li change&quot;&gt;
			&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;套餐办理与变更&lt;/span&gt;&lt;/a&gt;
			&lt;ul&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;GPRS套餐变更&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;产品变更&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;li score&quot;&gt;
			&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;积分计划&lt;/span&gt;&lt;/a&gt;
			&lt;ul&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;积分查询&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;积分兑换&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;积分明细查询&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;积分兑换话费&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;积分兑换历史查询&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;li server&quot;&gt;
			&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;在线客服&lt;/span&gt;&lt;/a&gt;
			&lt;ul&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;号码归属地查询&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;营业厅查询&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;手机仿真&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;在线咨询&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;li edit&quot;&gt;
			&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;&lt;span&gt;个人信息管理&lt;/span&gt;&lt;/a&gt;
			&lt;ul&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;个人资料修改&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;服务密码变更&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;服务密码重置&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;PUK码查询&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;套餐使用状态查询&lt;/a&gt;&lt;/li&gt;
				&lt;li class=&quot;li&quot;&gt;&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;业务开通状态查询&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;li sms&quot;&gt;
			&lt;a href=&quot;#nogo&quot; class=&quot;option&quot;&gt;短信息服务&lt;/a&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_EDvvg4');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_EDvvg4');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_EDvvg4','runcode_EDvvg4');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>原文：<a href="http://www.14px.com/?p=148" target="_blank">http://www.14px.com/?p=148</a></p>
<p><strong>9、em实现倒三角的提示效果:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_xs3aeJ">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;em实现倒三角的提示效果&lt;/title&gt;
&lt;/head&gt;
&lt;style&gt;
 &lt;!--
 #menu {width:500px;padding:0;margin:40px auto;list-style-type:none;display:&lt;span href=&quot;tag.php?name=tab&quot; onclick=&quot;tagshow(event)&quot; class=&quot;t_tag&quot;&gt;tab&lt;/span&gt;le;}
 #menu li {width:100px; float:left; line-height:30px}
 #menu a {position:relative;display:block; text-decoration:none; background:#cccccc;width:100px; }
 #menu a span {display:block; font-weight:bold;color:#000; border-style:solid;border-width:0px 2px 2px 0px; border-color:#fff #fff #06a #fff;text-align:center; }#menu a em {display:none;}
 #menu a:hover {background:#FF0000;}#menu a:hover span {color:#fff; }
 #menu a:hover em {display:block; overflow:hidden; border:6px solid #06a; border-color:#06a #fff; border-width:6px 6px 0 6px; position:absolute; left:50%; top:100%;margin-left:-6px;}
 --&gt;
 &lt;/style&gt;
&lt;body&gt;
 &lt;ul id=&quot;menu&quot;&gt;
 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;M One&lt;/span&gt;&lt;em&gt;&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;M Two&lt;/span&gt;&lt;em&gt;&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;M Three&lt;/span&gt;&lt;em&gt;&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;M Four&lt;/span&gt;&lt;em&gt;&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
 &lt;/ul&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_xs3aeJ');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_xs3aeJ');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_xs3aeJ','runcode_xs3aeJ');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>10、模拟表格对角线:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_ZxbmvV">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;模拟表格对角线&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{padding:0;margin:0;}
caption{font-size:14px;font-weight:bold;}
table{ border-collapse:collapse;border:1px #525152 solid;width:50%;margin:0 auto;margin-top:100px;}
th,td{border:1px #525152 solid;text-align:center;font-size:12px;line-height:30px;background:#C6C7C6;}
th{background:#D6D3D6;}
/*模拟对角线*/
.out{
   border-top:40px #D6D3D6 solid;/*上边框宽度等于表格第一行行高*/
   width:0px;/*让容器宽度为0*/
   height:0px;/*让容器高度为0*/
   border-left:80px #BDBABD solid;/*左边框宽度等于表格第一行第一格宽度*/
   position:relative;/*让里面的两个子容器绝对定位*/
}
b{font-style:normal;display:block;position:absolute;top:-40px;left:-40px;width:35px;}
em{font-style:normal;display:block;position:absolute;top:-25px;left:-70px;width:55x;}
.t1{background:#BDBABD;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table&gt;
  &lt;caption&gt;用div+css模拟表格对角线&lt;/caption&gt;
  &lt;tr&gt;
    &lt;th style=&quot;width:80px;&quot;&gt;
		&lt;div class=&quot;out&quot;&gt;
			&lt;b&gt;类别&lt;/b&gt;
			&lt;em&gt;姓名&lt;/em&gt;
		&lt;/div&gt;
	&lt;/th&gt;
    &lt;th&gt;年级&lt;/th&gt;
    &lt;th&gt;班级&lt;/th&gt;
    &lt;th&gt;成绩&lt;/th&gt;
    &lt;th&gt;班级均分&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class=&quot;t1&quot;&gt;张三&lt;/td&gt;
    &lt;td&gt;三&lt;/td&gt;
    &lt;td&gt;2&lt;/td&gt;
    &lt;td&gt;62&lt;/td&gt;
    &lt;td&gt;61&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class=&quot;t1&quot;&gt;李四&lt;/td&gt;
    &lt;td&gt;三&lt;/td&gt;
    &lt;td&gt;1&lt;/td&gt;
    &lt;td&gt;48&lt;/td&gt;
    &lt;td&gt;67&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class=&quot;t1&quot;&gt;王五&lt;/td&gt;
    &lt;td&gt;三&lt;/td&gt;
    &lt;td&gt;5&lt;/td&gt;
    &lt;td&gt;79&lt;/td&gt;
    &lt;td&gt;63&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class=&quot;t1&quot;&gt;赵六&lt;/td&gt;
    &lt;td&gt;三&lt;/td&gt;
    &lt;td&gt;4&lt;/td&gt;
    &lt;td&gt;89&lt;/td&gt;
    &lt;td&gt;66&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_ZxbmvV');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_ZxbmvV');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_ZxbmvV','runcode_ZxbmvV');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>11、纯CSS小三角:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_iQC9hX">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt;小三角&lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;style&gt;
*{ margin:0; padding:0; font-size:12px; font-family:Verdana, &quot;宋体&quot;, Arial; line-height:1.8; list-style:none;}
#info,#nav{ margin:50px; border:1px dashed #FF3300; background:#FFFFCC; padding:50px;}
#info div{background:#FF0000; width:0px; height:0px; overflow:hidden; margin-bottom:10px;}
/*一些三角的写法*/
#com_a{ border-top:10px solid #FFFFCC;border-left:10px solid #FF3300;border-bottom:10px solid #FFFFCC;}
#com_b{ border-top:10px solid #FFFFCC;border-right:10px solid #FF3300;border-bottom:10px solid #FFFFCC;}
#com_c{ border-top:10px solid #FFFFCC;border-right:10px solid #FF3300;border-bottom:10px solid #FFFFCC;border-left:10px solid #FF3300;}
#com_d{ border-top:10px solid #FF3300;border-right:10px solid #FFFFCC;border-bottom:10px solid #FF3300;border-left:10px solid #FFFFCC;}
#com_e{ border-top:10px solid #FFFFCC;border-left:10px solid #FF3300;}
#com_f{ border-top:10px solid #FF3300;border-right:10px solid #FFFFCC;border-left:10px solid #FFFFCC;}
#com_g{ border-right:10px solid #FFFFCC;border-bottom:10px solid #FF3300;border-left:10px solid #FFFFCC;}
#com_h{ border-top:10px solid #FF3300;border-bottom:10px solid #FF3300;border-left:10px solid #FFFFCC;}
#com_i{ border-top:10px solid #FF3300;border-right:10px solid #FF3300;border-bottom:10px solid #FF3300;border-left:10px solid #FFFFCC;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;info&quot;&gt;
&lt;h1&gt;一些三角形的写法&lt;/h1&gt;
  &lt;div id=&quot;com_a&quot;&gt;&lt;/div&gt;
  &lt;div id=&quot;com_b&quot;&gt;&lt;/div&gt;
  &lt;div id=&quot;com_f&quot;&gt;&lt;/div&gt;
  &lt;div id=&quot;com_g&quot;&gt;&lt;/div&gt;
  &lt;div id=&quot;com_c&quot;&gt;&lt;/div&gt;
  &lt;div id=&quot;com_d&quot;&gt;&lt;/div&gt;
  &lt;div id=&quot;com_e&quot;&gt;&lt;/div&gt;
  &lt;div id=&quot;com_h&quot;&gt;&lt;/div&gt;
  &lt;div id=&quot;com_i&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_iQC9hX');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_iQC9hX');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_iQC9hX','runcode_iQC9hX');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>12、纯CSS超过宽度显示省略号:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_SQNq9Y">
  &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;纯CSS超过宽度显示省略号(www.hemin.cn)&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{ margin:0; padding:0; font-size:12px; font-family:&quot;新宋体&quot;;}
ol{ background:url(http://www.hemin.cn/blog/wp-content/uploads/2009/06/list.jpg) no-repeat left -2px;}
li{position:relative; padding:0 60px 0 20px;  height:20px; overflow:hidden; line-height:20px; width:250px; list-style:none;}
li a{ position:relative;background: url(http://www.hemin.cn/blog/wp-content/uploads/2009/10/pot.gif) no-repeat 230px top;display:inline-block; text-decoration:none; color:#000; padding-right:12px; margin-right:10px;}
li a:hover{ text-decoration:underline;}
li a em{width:10px; height:18px; overflow:hidden;background:#FFF; position:absolute;right:0; bottom:0; text-indent:-999px;}
li span{ position:absolute; padding-left:5px;  color:#CCC;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;ol&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;杂技团美女演员的训练&lt;em&gt;...&lt;/em&gt;&lt;/a&gt;&lt;span&gt;2009-6-21&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;杂技团美女演员的训练演员的训练演员的训练训练演员的训练演员的训练训练演员的训练演员的训练训演员的训练演员的训练&lt;em&gt;...&lt;/em&gt;&lt;/a&gt;&lt;span&gt;2009-6-21&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;杂技团美女演员的训练演员的训练演员的训练训练演员的训练演员的训练训练演员的训练演员的训练练演员的训练演员的训练&lt;em&gt;...&lt;/em&gt;&lt;/a&gt;&lt;span&gt;2009-6-21&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;杂技团美女演员的训练演员的训练演员的训练训练演员的训练演员的训练训练演员的训练演员的训练训演员的训练演员的训练&lt;em&gt;...&lt;/em&gt;&lt;/a&gt;&lt;span&gt;2009-6-21&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;练演员的训练&lt;em&gt;...&lt;/em&gt;&lt;/a&gt;&lt;span&gt;2009-6-21&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;练演员的训演员的训练&lt;em&gt;...&lt;/em&gt;&lt;/a&gt;&lt;span&gt;2009-6-21&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;练演员的训练演员的训练练&lt;em&gt;...&lt;/em&gt;&lt;/a&gt;&lt;span&gt;2009-6-21&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;练演员的练&lt;em&gt;...&lt;/em&gt;&lt;/a&gt;&lt;span&gt;2009-6-21&lt;/span&gt;&lt;/li&gt;
    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;练演员的训练&lt;em&gt;...&lt;/em&gt;&lt;/a&gt;&lt;span&gt;2009-6-21&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_SQNq9Y');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_SQNq9Y');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_SQNq9Y','runcode_SQNq9Y');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>13、纯CSS图片放大效果:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_Nbe2OQ">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;META NAME=&quot;Author&quot; CONTENT=&quot;hhshushu&quot; /&gt;
&lt;META NAME=&quot;Keywords&quot; CONTENT=&quot;纯CSS图片放大效果&quot; /&gt;
&lt;META NAME=&quot;Description&quot; CONTENT=&quot;纯CSS图片放大效果&quot; /&gt;
&lt;title&gt;纯CSS图片放大效果&lt;/title&gt;
&lt;style type=&quot;text/css&quot; title=&quot;&quot;&gt;
	body{width:320px;margin:0 auto;padding:20px;background:#000;color:#000;}
	#main-content{border:5px solid #7bc809;padding:5px;background:#fff ;}
	ul{ margin:0;padding:0;list-style:none;padding-bottom:300px; /*padding给图片撑开空间*/}
    li{display:inline;}
	li a{position:relative;}
	li a:hover{position:relative;border:none;z-index:1000;}/*此处要有border:none属性，否则IE6下面无法显示出来，是IE6伪类的BUG*/
	li a img{width:100px;height:100px;border:none;position:absolute;}/*使用绝对定位让图片固定，从而脱离页面流*/
	li a:hover img{position: absolute;left:-10px;top:-50px;width:240px;height:240px;padding:5px;background:#fff;border:2px solid #000;z-index:1000;} /*注意这里的z-index显示设置，否则会有重叠*/
	li#pic-01 a img{top:0;left:0;}
	li#pic-02 a img{top:0;left:100px;}
	li#pic-03 a img{top:0;left:200px;}
	li#pic-04 a img{top:100px;left:0;}
	li#pic-05 a img{top:100px;left:100px;}
	li#pic-06 a img{top:100px;left:200px;}
	li#pic-07 a img{top:200px;left:0px;}
	li#pic-08 a img{top:200px;left:100px;}
	li#pic-09 a img{top:200px;left:200px;}/*定位图片的排布*/
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;main-content&quot; &gt;
	&lt;ul&gt;
		&lt;li id=&quot;pic-01&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://ued.alipay.com/wp-content/uploads/2008/10/01.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li id=&quot;pic-02&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://ued.alipay.com/wp-content/uploads/2008/10/02.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li id=&quot;pic-03&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://ued.alipay.com/wp-content/uploads/2008/10/03.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li id=&quot;pic-04&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://ued.alipay.com/wp-content/uploads/2008/10/04.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li id=&quot;pic-05&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://ued.alipay.com/wp-content/uploads/2008/10/05.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li id=&quot;pic-06&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://ued.alipay.com/wp-content/uploads/2008/10/06.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li id=&quot;pic-07&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://ued.alipay.com/wp-content/uploads/2008/10/07.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li id=&quot;pic-08&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://ued.alipay.com/wp-content/uploads/2008/10/08.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li id=&quot;pic-09&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://ued.alipay.com/wp-content/uploads/2008/10/09.jpg&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_Nbe2OQ');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_Nbe2OQ');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_Nbe2OQ','runcode_Nbe2OQ');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>转：<a href="http://ued.alipay.com/?p=117" target="_blank">http://ued.alipay.com/?p=117</a></p>
<p><strong>14、五星红旗:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_EZGark">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb18030&quot; /&gt;
&lt;title&gt;五星红旗&lt;/title&gt;
&lt;style&gt;
html,body{ margin:0; padding:0;}
body{ width:1300px; height:800px;}
.clear{ clear:both;}
#corner{
	position:relative;
	width:0px;
	height:0px;
	overflow:hidden;
	border-top:30.8px solid #f00;
	border-right:10.0px solid #ff0;
	float:left;
	display:inline;
	margin-left:32.4px;
}
#corner2{
	position:relative;
	width:0px;
	height:0px;
	overflow:hidden;
	border-top:30.8px solid #f00;
	border-left:10.0px solid #ff0;
	float:left;
	display:inline;
}
#nav{
	position:relative;
	width:0px;
	height:0px;
	overflow:hidden;
	border-top:30.8px solid #ff0;
	border-left:42.4px solid #f00;
	float:left;
	display:inline;
}
#nav2{
	position:relative;
	width:0px;
	height:0px;
	overflow:hidden;
	border-top:30.8px solid #ff0;
	border-right:42.4px solid #f00;
	float:left;
	display:inline;
}
#foot{
	position:relative;
	width:28.9px;
	height:26.5px;
	background-color:#ff0;
	float:left;
	display:inline;
	margin-left:13.5px;
	overflow:hidden;
	z-index:5;
	margin-top:-11.2px;
}
#foot2{
	position:relative;
	width:28.9px;
	height:26.5px;
	background-color:#ff0;
	float:left;
	display:inline;
	overflow:hidden;
	z-index:5;
	margin-top:-11.2px;
}
#fb{
	position:relative;
	width:0px;
	height:0px;
	overflow:hidden;
	border-top:14.7px solid #ff0;
	border-right:28.9px solid #f00;
	float:left;
	display:inline;
	margin-top:11.8px;
	margin-top:12px;
	z-index:10;
}
#fb2{
	position:relative;
	width:0px;
	height:0px;
	overflow:hidden;
	border-top:14.7px solid #ff0;
	border-left:28.9px solid #f00;
	float:left;
	display:inline;
	margin-top:11.8px;
	margin-top:12px;
	z-index:10;
}
#ft{
	position:relative;
	width:0px;
	height:0px;
	overflow:hidden;
	border-top:26.5px solid #f00;
	border-right:13.5px solid transparent;
	float:left;
	display:inline;
	z-index:13;
	margin-top:-26.6px;
}
#ft2{
	position:relative;
	width:0px;
	height:0px;
	overflow:hidden;
	border-top:26.5px solid #f00;
	border-left:13.5px solid transparent;
	float:right;
	display:inline;
	z-index:13;
	margin-top:-26.6px;
}
#one{
	width:0px;height:0px;
	border-top:250px #ff0 solid;
	border-right:250px #000 solid;
	border-left:green 250px solid;
	border-bottom:red 250px solid;
	position:absolute;
	top:1000px;
}
#flag{
	width:1000px;
	height:700px;
	position:absolute;
	border:1px solid #ff6600;
	background-color:#f00;
	top:50px;
	left:50px;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;flag&quot;&gt;&lt;/div&gt;
&lt;div id=&quot;star&quot; style=&quot;position:absolute;top:100px;left:100px;&quot;&gt;
	&lt;div id=&quot;corner&quot;&gt;&lt;/div&gt;&lt;div id=&quot;corner2&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;nav&quot;&gt;&lt;/div&gt;&lt;div id=&quot;nav2&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;foot&quot;&gt;
		&lt;div id=&quot;fb&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;ft&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
	&lt;div id=&quot;foot2&quot;&gt;
		&lt;div id=&quot;fb2&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;ft2&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;star&quot; style=&quot;position:absolute;top:80px;left:330px;&quot;&gt;
	&lt;div id=&quot;corner&quot;&gt;&lt;/div&gt;&lt;div id=&quot;corner2&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;nav&quot;&gt;&lt;/div&gt;&lt;div id=&quot;nav2&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;foot&quot;&gt;
		&lt;div id=&quot;fb&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;ft&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
	&lt;div id=&quot;foot2&quot;&gt;
		&lt;div id=&quot;fb2&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;ft2&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;star&quot; style=&quot;position:absolute;top:180px;left:360px;&quot;&gt;
	&lt;div id=&quot;corner&quot;&gt;&lt;/div&gt;&lt;div id=&quot;corner2&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;nav&quot;&gt;&lt;/div&gt;&lt;div id=&quot;nav2&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;foot&quot;&gt;
		&lt;div id=&quot;fb&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;ft&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
	&lt;div id=&quot;foot2&quot;&gt;
		&lt;div id=&quot;fb2&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;ft2&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;star&quot; style=&quot;position:absolute;top:280px;left:330px;&quot;&gt;
	&lt;div id=&quot;corner&quot;&gt;&lt;/div&gt;&lt;div id=&quot;corner2&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;nav&quot;&gt;&lt;/div&gt;&lt;div id=&quot;nav2&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;foot&quot;&gt;
		&lt;div id=&quot;fb&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;ft&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
	&lt;div id=&quot;foot2&quot;&gt;
		&lt;div id=&quot;fb2&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;ft2&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;star&quot; style=&quot;position:absolute;top:360px;left:250px;&quot;&gt;
	&lt;div id=&quot;corner&quot;&gt;&lt;/div&gt;&lt;div id=&quot;corner2&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;nav&quot;&gt;&lt;/div&gt;&lt;div id=&quot;nav2&quot;&gt;&lt;/div&gt;
	&lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;foot&quot;&gt;
		&lt;div id=&quot;fb&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;ft&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
	&lt;div id=&quot;foot2&quot;&gt;
		&lt;div id=&quot;fb2&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;ft2&quot;&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_EZGark');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_EZGark');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_EZGark','runcode_EZGark');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>15、css3写的几面国旗:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_bV7_3S">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;几面国旗 - 人生旅途中&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
	body{ background-color:#D0DADF;}
	.flag{ width:450px; height:300px;box-shadow:5px 5px 5px #333; -moz-box-shadow:5px 5px 5px #333; float:left; margin:0px 15px 15px; -webkit-box-shadow:5px 5px 5px #999; position:relative; overflow:hidden;}
	.china{ background-color:#F00;}
	.china .bigStar{ color:#FF0; font-size:96px; position:absolute; top:20px; left:21px;}
	.china .smallStar{ color:#FF0; position:absolute; font-size:28px;}
	.china .one{-o-transform:rotate(23deg); -moz-transform:rotate(23deg); -webkit-transform:rotate(23deg); top:18px; left:143px;}
	.china .two{ -o-transform:rotate(46deg); -moz-transform:rotate(46deg); -webkit-transform:rotate(46deg); top:49px; left:173px;}
	.china .three{ -o-transform:rotate(0deg); -moz-transform:rotate(0deg); -webkit-transform:rotate(0deg); top:93px; left:167px;}
	.china .four{-o-transform:rotate(23deg); -moz-transform:rotate(23deg); -webkit-transform:rotate(23deg); top:129px; left:140px;}
	.congo{ background: #008836;}
	.congo .yellow{ width:150px; height:300px; -o-transform:skew(-45deg,0deg); -moz-transform:skew(-45deg,0deg); -webkit-transform:skew(-45deg,0deg); position:absolute; left:150px; background-color:#FEFE00;}
	.congo .red{ width:425px; height:425px; background-color:#F00; -o-transform:rotate(45deg); -moz-transform:rotate(45deg); -webkit-transform:rotate(45deg); position:absolute; top:88px; left:237px;}
	.korea{ background: #FEFEFE;}
	.korea .threeLine{ width:76px; position:absolute;}
	.korea .line{ width:76px;height:17px; background-color:#000000; margin-bottom:6px; position:relative;}
	.korea .line_dir_1{-o-transform:rotate(-48deg); -moz-transform:rotate(-48deg); -webkit-transform:rotate(-48deg); top:32px; left:55px;}
	.korea .line_dir_2{ -o-transform:rotate(48deg); -moz-transform:rotate(48deg); -webkit-transform:rotate(48deg); top:33px; right:57px;}
	.korea .line_dir_3{ -o-transform:rotate(48deg); -moz-transform:rotate(48deg); -webkit-transform:rotate(48deg); top:211px; left:51px;}
	.korea .line_dir_4{ -o-transform:rotate(-48deg);  -moz-transform:rotate(-48deg); -webkit-transform:rotate(-48deg); top:211px; right:52px;}
	.korea .zindex_0{ z-index:0;}
	.korea .zindex_1{ z-index:1;}
	.korea .vline{ width:17px; height:65px; background-color:#fff; position:absolute; top:-1px; left:29px; z-index:1}
	.korea .mround{ width:180px; height:180px; border-radius:90px; -moz-border-radius:90px; -webkit-border-radius:90px; background-color:#FE0000; position:absolute; top:62px; left:128px;-o-transform:rotate(22deg); -moz-transform:rotate(22deg); -webkit-transform:rotate(22deg);}
	.korea .halfblueround{ width:180px; height:90px; border-radius:0px 0px 90px 90px;  -moz-border-radius:0px 0px 90px 90px; -webkit-border-radius:0px; -webkit-border-bottom-left-radius:90px; -webkit-border-bottom-right-radius:90px;/*解决safari半圆显示问题*/background-color:#0B4199;position:absolute; bottom:0px;}
	.korea .Shalfblueround{ width:90px; height:45px; border-radius:45px 45px 0px 0px; -moz-border-radius:45px 45px 0px 0px; -webkit-border-radius:0px; -webkit-border-top-left-radius:45px; -webkit-border-top-right-radius:45px;background-color:#0B4199; position:absolute; right:0px; top:46px;}
	.korea .Shalfredround{ width:90px; height:45px; border-radius:0px 0px 45px 45px; -moz-border-radius:0px 0px 45px 45px; -webkit-border-radius:0px; -webkit-border-bottom-left-radius:45px; -webkit-border-bottom-right-radius:45px;background-color:#FE0000; position:absolute; left:0px; top:89px;}
	.tuerqi{ background:#FE0000;}
	.tuerqi .whiteRound{ width:156px; height:156px; background-color:#FEFEFE;border-radius:78px; -moz-border-radius:78px; -webkit-border-radius:78px; position:absolute; top:72px; left:88px;}
	.tuerqi .redRound{ width:126px; height:126px; background-color:#FE0000;border-radius:63px; -moz-border-radius:63px; -webkit-border-radius:63px; position:absolute; top:87px; left:123px;}
	.tuerqi .Star{ color:#fff; font-size:60px; position:absolute; top:113px; left:226px; transform:rotate(-16deg); -o-transform:rotate(-16deg);-moz-transform:rotate(-16deg); -webkit-transform:rotate(-16deg);}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div class=&quot;flag china&quot;&gt;
    	&lt;div class=&quot;bigStar&quot;&gt;★&lt;/div&gt;
        &lt;div class=&quot;smallStar one&quot;&gt;★&lt;/div&gt;
        &lt;div class=&quot;smallStar two&quot;&gt;★&lt;/div&gt;
        &lt;div class=&quot;smallStar three&quot;&gt;★&lt;/div&gt;
        &lt;div class=&quot;smallStar four&quot;&gt;★&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;flag congo&quot;&gt;
    	&lt;div class=&quot;yellow&quot;&gt;&lt;/div&gt;
        &lt;div class=&quot;red&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;flag korea&quot;&gt;
    	&lt;div class=&quot;threeLine line_dir_1&quot;&gt;
        	&lt;div class=&quot;line&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;line&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;line&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;threeLine line_dir_2&quot;&gt;
            &lt;div class=&quot;vline&quot;&gt;&lt;/div&gt;
        	&lt;div class=&quot;line zindex_0&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;line zindex_1&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;line zindex_0&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;threeLine line_dir_3&quot;&gt;
            &lt;div class=&quot;vline&quot;&gt;&lt;/div&gt;
        	&lt;div class=&quot;line zindex_1&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;line zindex_0&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;line zindex_1&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;threeLine line_dir_4&quot;&gt;
            &lt;div class=&quot;vline&quot;&gt;&lt;/div&gt;
        	&lt;div class=&quot;line zindex_0&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;line zindex_0&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;line zindex_0&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class=&quot;mround&quot;&gt;
        	&lt;div class=&quot;halfblueround&quot;&gt;&lt;/div&gt;
            &lt;div class=&quot;Shalfredround&quot;&gt;&lt;/div&gt;
        	&lt;div class=&quot;Shalfblueround&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;flag tuerqi&quot;&gt;
    	&lt;div class=&quot;whiteRound&quot;&gt;&lt;/div&gt;
        &lt;div class=&quot;redRound&quot;&gt;&lt;/div&gt;
        &lt;div class=&quot;Star&quot;&gt;★&lt;/div&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_bV7_3S');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_bV7_3S');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_bV7_3S','runcode_bV7_3S');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>转：<a href="http://bbs.blueidea.com/thread-2985513-1-1.html" target="_blank">http://bbs.blueidea.com/thread-2985513-1-1.html</a></p>
<p><strong>16、CSS3 &#8211; 机器猫:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_AQ2Dus">
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
&lt;title&gt;CSS3 - 机器猫&lt;/title&gt;
&lt;style&gt;
body{
	background:#fff;
    width:901px;
    margin:auto;
}
#doraemon{
	position:fixed;
	margin:50px;
	float:left;
	width:500px;
}
#instr{
	float:right;
	width:400px;
	font-size:14px;
	border-left:2px solid black;
	padding-left:20px;
}
#head_light{
	width:50px;
	height:50px;
	transform: rotate(20deg);
		-webkit-transform: rotate(20deg);
		-moz-transform: rotate(20deg);
		-o-transform: rotate(20deg);
	box-shadow:80px 20px 50px #fff;
		-webkit-box-shadow:80px 20px 55px #fff;
		-moz-box-shadow:80px 20px 50px #fff;
	border-radius:45px;
		-webkit-border-radius:45px;
		-moz-border-radius:60px;
	position:absolute;
	top:-20px;
	left:170px;
	opacity:0.5
}
#face{
	position:relative;
	width:310px;
	height:300px;
	border-radius:146px;
		-webkit-border-radius:146px;
		-moz-border-radius:146px;
	background:#07beea;
	background: -webkit-gradient(linear, right top, left bottom, from(#fff) ,color-stop(0.20, #07beea), color-stop(0.73, #10a6ce),color-stop(0.95, #000), to(#444));
	background: -moz-linear-gradient(right top, #fff,#07beea 20%, #10a6ce 73% ,#000 95% ,#000 155%);
	border:#333 2px solid;
	top:-15px;
	box-shadow:-5px 10px 15px rgba(0,0,0,0.45);
		-webkit-box-shadow:-5px 10px 15px rgba(0,0,0,0.45);
		-moz-box-shadow:-5px 10px 15px rgba(0,0,0,0.45);
}
#base{
	position:relative;
	top:-5px;
}
#base_white{
	position:absolute;
	border:#000 2px solid;
	width:264px;
	height:196px;
	border-radius: 150px 150px;
		-webkit-border-radius: 150px 150px;
		-moz-border-radius: 150px 150px;
	background:#FFF;
	background: -webkit-gradient(linear, right top, left bottom, from(#fff),color-stop(0.75,#fff),color-stop(0.83,#eee),color-stop(0.90,#999),color-stop(0.95,#444), to(#000));
	background: -moz-linear-gradient(right top, #fff,#fff 75%, #eee 83%,#999 90%,#444 95%, #000);
	z-index:1;
	top:85px;
	left:22px;
}
#eyes{
	position:relative;
	top:-5px;
}
div.eye{
	position:absolute;
	border-radius: 35px 35px;
		-webkit-border-radius: 35px 35px;
		-moz-border-radius: 35px 35px;
	border:2px solid #000;
	width:72px;
	height:83px;
	z-index:20;
	background:#fff;
}
div.black_eye{
	position:absolute;
	width:15px;
	height:15px;
	border-radius:10px;
		-webkit-border-radius:10px;
		-moz-border-radius:10px;
	background:#333;
	z-index:21;
		-webkit-animation-name: cate;
		-webkit-animation-duration: 3s;
		-webkit-animation-timing-function: linear;
		-webkit-animation-iteration-count: 200;
}
@-webkit-keyframes cate{
	0%{
		margin:0 0 0 0;
	}
	80%	{
		margin:0px 0 0 0;
	}
	85%	{
		margin:-20px 0 0 0;
	}
	90%{
		margin:0 0 0 0;
	}
	93%{
		margin:0 0 0 7px;
	}
	96%{
		margin:0 0 0 0;
	}
	100%{
		margin:0 0 0 0;
	}
}
div.black_left{
	top:100px;
	left:130px;
}
div.black_right{
	top:100px;
	left:170px;
}
div.eye_left{
	top:45px;
	left:82px;
}
div.eye_right{
	top:45px;
	left:156px;
}
#nose{
	width:32px;
	height:32px;
	border:2px solid #000;
	border-radius:50px;
		-webkit-border-radius:50px;
		-moz-border-radius:50px;
	background:#c93e00;
	position:absolute;
	top:117px;
	left:139px;
	z-index:30;
}
#nose_light{
	width:10px;
	height:10px;
	border-radius:5px;
		-webkit-border-radius:5px;
		-moz-border-radius:5px;
	box-shadow:19px 8px 5px #fff;
		-webkit-box-shadow:19px 8px 5px #fff;
		-moz-box-shadow:19px 8px 5px #fff;
	position:relative;
	top:0px;
	left:0px;
}
#nose_line{
	background:#000;
	width:4px;
	height:100px;
	top:125px;
	left:156px;
	position:absolute;
}
#nose_line{
	background:#333;
	width:3px;
	height:100px;
	top:140px;
	left:155px;
	position:absolute;
		z-index:20;
}
#mouth{
	width:240px;
	height:500px;
	border-bottom:3px solid #333;
	border-radius:120px;
		-webkit-border-radius:120px;
		-moz-border-radius:120px;
	position:absolute;
	top:-263px;
	left:36px;
	z-index:10;
}
#mouth_rewrite{
	background:#fff;
	width:240px;
	height:90px;
	position:relative;
	top:115px;
	left:35px;
	z-index:12;
	border-radius:45px;
		-webkit-border-radius:45px;
		-moz-border-radius:60px;
}
#firefox_mouth, x:-moz-broken, x:last-of-type, x:indeterminate {
	position:relative;
	width:170px;
	height:150px;
	-moz-border-radius:85px;
	border:3px solid #000;
	background:#FFF;
	z-index:11;
	top:-3px;
	left:70px;
}
.whiskers{
	background:#333;
	height:2px;
	width:60px;
	position:absolute;
	z-index:20;
}
.whi_right{
	top:165px;
	left:210px;
}
.whi_right_top{
	top:145px;
	left:210px;
}
.whi_right_bottom{
	top:185px;
	left:210px;
}
.whi_left{
	top:165px;
	left:50px;
}
.whi_left_top{
	top:145px;
	left:50px;
}
.whi_left_bottom{
	top:185px;
	left:50px;
}
.rotate20{
	transform: rotate(20deg);
		-webkit-transform: rotate(20deg);
		-moz-transform: rotate(20deg);
		-o-transform: rotate(20deg);
}
.rotate160{
	transform: rotate(160deg);
		-webkit-transform: rotate(160deg);
		-moz-transform: rotate(160deg);
		-o-transform: rotate(160deg);
}
#choker{
	position:relative;
	top:-55px;
	left:35px;
	z-index:100;
}
#belt{
	width:230px;
	height:20px;
	border:#000 solid 2px;
	background:#ca4100;
	background: -webkit-gradient(linear, left top, left bottom, from(#ca4100), to(#800400));
	background: -moz-linear-gradient(top, #ca4100, #800400);
	border-radius:10px;
		-webkit-border-radius:10px;
		-moz-border-radius:10px;
		position:relative;
	left:5px;
}
#bell{
	width:40px;
	height:40px;
	border-radius:50px;
		-webkit-border-radius:50px;
		-moz-border-radius:50px;
	border:2px solid #000;
	background:#f9f12a;
	background: -webkit-gradient(linear, left top, left bottom, from(#f9f12a),color-stop(0.5, #e9e11a), to(#a9a100));
	background: -moz-linear-gradient(top, #f9f12a, #e9e11a 75%,#a9a100);
	box-shadow:-5px 5px 10px rgba(0,0,0,0.25);
		-webkit-box-shadow:-5px 3px 5px rgba(0,0,0,0.25);
		-moz-box-shadow:-5px 5px 10px rgba(0,0,0,0.25);
	position:relative;
	top:-15px;
	left:100px;
}
#bell_line{
	width:36px;
	height:2px;
	background:#f9f12a;
	border:#333 solid 2px;
	position:relative;
	top:10px;
}
#bell_circle{
	width:12px;
	height:10px;
	border-radius:5px;
		-webkit-border-radius:5px;
		-moz-border-radius:5px;
	background:#000;
	position:relative;
	top:14px;
	left:14px;
}
#bell_under{
	width:3px;
	height:15px;
	background:#000;
	position:relative;
	top:10px;
	left:18px;
}
#bell_light{
	width:10px;
	height:10px;
	border-radius:10px;
		-webkit-border-radius:10px;
		-moz-border-radius:10px;
	box-shadow:19px 8px 5px #fff;
		-webkit-box-shadow:19px 8px 5px #fff;
		-moz-box-shadow:19px 8px 5px #fff;
	position:relative;
	opacity:0.7;
	top:-35px;
	left:5px;
}
#doutai{
	position:absolute;
	width:220px;
	height:165px;
	background:#07beea;
	background: -webkit-gradient(linear, right top, left top, from(#07beea),color-stop(0.5, #0073b3),color-stop(0.75,#00b0e0), to(#0096be));
	background: -moz-linear-gradient(right, #07beea, #0073b3 50%,#0096be 75%,#00b0e0 ,#0096be 100% ,#333 114%);
	border:#333 2px solid;
	top:262px;
	left:46px;
}
div.base_white2{
	position:absolute;
	width:170px;
	height:170px;
	border-radius:85px;
		-webkit-border-radius:85px;
		-moz-border-radius:85px;
	border:2px solid #000;
	background:#FFF;
	background: -webkit-gradient(linear, right top, left bottom, from(#fff),color-stop(0.75,#fff),color-stop(0.83,#eee),color-stop(0.90,#999),color-stop(0.95,#444), to(#000));
	background: -moz-linear-gradient(right top, #fff,#fff 75%, #eee 83%,#999 90%,#444 95%, #000);
}
.doutai_center{
	top:230px;
	left:72px;
}
#circle{
	position:relative;
	width:130px;
	height:130px;
	border-radius:65px;
		-webkit-border-radius:65px;
		-moz-border-radius:65px;
	background:#fff;
	background: -webkit-gradient(linear, right top, left bottom, from(#fff),color-stop(0.70,#fff),color-stop(0.75,#f8f8f8),color-stop(0.80,#eee),color-stop(0.88,#ddd), to(#fff));
	background: -moz-linear-gradient(right top, #fff, #fff 70%,#f8f8f8 75%,#eee 80%,#ddd 88% , #fff);
	border:2px solid #000;
	top:-120px;
	left:92px;
}
#circle_rewrite{
	position:relative;
	width:134px;
	height:60px;
	background:#fff;
	border-bottom:2px solid #000;
	top:-250px;
	left:92px;
}
#hand_right{
	position:absolute;
	top:272px;
	left:248px;
	width:100px;
	height:100px;
}
#arm_right{
	position:relative;
	width:80px;
	height:50px;
	background:#07beea;
	background: -webkit-gradient(linear, left top, left bottom, from(#07beea),color-stop(0.85,#07beea), to(#555));
	background: -moz-linear-gradient(top, #07beea, #07beea 85%, #555);
	border:solid 1px #000;
	z-index:-1;
	top:17px;
	transform: rotate(35deg);
		-webkit-transform: rotate(35deg);
		-moz-transform: rotate(35deg);
		-o-transform: rotate(35deg);
	box-shadow:-10px 7px 10px rgba(0,0,0,0.35);
		-webkit-box-shadow:-10px 7px 10px rgba(0,0,0,0.35);
		-moz-box-shadow:-10px 7px 10px rgba(0,0,0,0.35);
}
#hand_left{
	position:absolute;
	top:272px;
	left:-46px;
	width:100px;
	height:100px;
}
#arm_left{
	position:relative;
	width:80px;
	height:50px;
	background:#0096be;
	border:solid 1px #000;
	z-index:-1;
	top:17px;
	left:36px;
	transform: rotate(145deg);
		-webkit-transform: rotate(145deg);
		-moz-transform: rotate(145deg);
		-o-transform: rotate(145deg);
	box-shadow:5px -7px 10px rgba(0,0,0,0.25);
		-webkit-box-shadow:5px -7px 10px rgba(0,0,0,0.25);
		-moz-box-shadow:5px -7px 10px rgba(0,0,0,0.25);
}
div.hand_circle{
	position:absolute;
	width:60px;
	height:60px;
	border-radius:30px;
		-webkit-border-radius:30px;
		-moz-border-radius:30px;
	border:2px solid #000;
	background:#fff;
	background: -webkit-gradient(linear, right top, left bottom, from(#fff),color-stop(0.5,#fff),color-stop(0.70,#eee),color-stop(0.8,#ddd), to(#999));
	background: -moz-linear-gradient(right top, #fff, #fff 50%, #eee 70%, #ddd 80%,#999);
}
.hand_right{
	top:32px;
	left:40px;
}
.arm_rewrite_right{
	position:relative;
	width:4px;
	height:45px;
	background:#07beea;
	top:-51px;
	left:18px;
}
.hand_left{
	top:34px;
	left:10px;
}
.arm_rewrite_left{
	position:relative;
	width:4px;
	height:50px;
	background:#0096be;
	top:-52px;
	left:92px;
}
#foot{
	position:relative;
	width:280px;
	height:40px;
	top:-141px;
	left:20px;
}
#foot_left{
	width:125px;
	height:30px;
	background:#fff;
	background: -webkit-gradient(linear, right top, left bottom, from(#fff),color-stop(0.75,#fff),color-stop(0.85,#eee), to(#999));
	background: -moz-linear-gradient(right top, #fff,#fff 75%, #eee 85%, #999);
	border:solid 2px #333;
	border-top-left-radius:80px;
	border-bottom-left-radius:40px;
	border-top-right-radius:60px;
	border-bottom-right-radius:60px;
		-webkit-border-top-left-radius:80px;
		-webkit-border-bottom-left-radius:40px;
		-webkit-border-top-right-radius:60px;
		-webkit-border-bottom-right-radius:60px;
		-moz-border-radius-topleft:80px;
		-moz-border-radius-bottomleft:40px;
		-moz-border-radius-topright:60px;
		-moz-border-radius-bottomright:60px;
	position:relative;
	left:8px;
	top:2px;
	box-shadow:-6px 0px 10px rgba(0,0,0,0.35);
		-webkit-box-shadow:-6px 0px 10px rgba(0,0,0,0.35);
		-moz-box-shadow:-6px 0px 10px rgba(0,0,0,0.35);
	z-index:-1;
}
#foot_right{
	position:relative;
	width:125px;
	height:30px;
	background:#fff;
	background: -webkit-gradient(linear, right top, left bottom, from(#fff),color-stop(0.75,#fff),color-stop(0.85,#eee), to(#999));
	background: -moz-linear-gradient(right top, #fff,#fff 75%, #eee 85%, #999);
	border:solid 2px #333;
	border-top-left-radius:60px;
	border-bottom-left-radius:60px;
	border-top-right-radius:80px;
	border-bottom-right-radius:40px;
		-webkit-border-top-left-radius:60px;
		-webkit-border-bottom-left-radius:60px;
		-webkit-border-top-right-radius:80px;
		-webkit-border-bottom-right-radius:40px;
		-moz-border-radius-topleft:60px;
		-moz-border-radius-bottomleft:60px;
		-moz-border-radius-topright:80px;
		-moz-border-radius-bottomright:40px;
	top:-32px;
	left:141px;
	box-shadow:-6px 0px 10px rgba(0,0,0,0.35);
		-webkit-box-shadow:-6px 0px 10px rgba(0,0,0,0.35);
		-moz-box-shadow:-6px 0px 10px rgba(0,0,0,0.35);
	z-index:-1;
}
#foot_rewrite{
	position:relative;
	width:20px;
	height:10px;
	background:#fff;
	background: -webkit-gradient(linear, right top, left bottom, from(#666),color-stop(0.83,#fff), to(#fff));
	background: -moz-linear-gradient(right top, #666, #fff 83%, #fff);
	top:-76px;
	left:127px;
	border-top:2px solid #000;
	border-right:2px solid #000;
	border-left:2px solid #000;
	border-top-right-radius:40px;
	border-top-left-radius:40px;
		-webkit-border-top-right-radius:40px;
		-webkit-border-top-left-radius:40px;
		-moz-border-radius-topleft:40px;
		-moz-border-radius-topright:40px;
}
#shadow_doutai_left{
	width:30px;
	height:200px;
	box-shadow:-10px 10px 15px rgba(0,0,0,0.45);
		-webkit-box-shadow:-10px 10px 15px rgba(0,0,0,0.45);
		-moz-box-shadow:-10px 10px 15px rgba(0,0,0,0.45);
	position:absolute;
	top:250px;
	left:46px;
	z-index:-10;
}
#shadow_doutai_right{
	width:30px;
	height:200px;
	box-shadow:10px 10px 15px rgba(0,0,0,0.35);
		-webkit-box-shadow:10px 10px 25px rgba(0,0,0,0.35);
		-moz-box-shadow:10px 10px 15px rgba(0,0,0,0.35);
	position:absolute;
	top:240px;
	left:230px;
	z-index:-10;
}
#shadow_doutai_arm{
	width:85px;
	height:165px;
	box-shadow:-100px 10px 15px rgba(0,0,0,0.0);
		-webkit-box-shadow:-100px 10px 15px rgba(0,0,0,0.25);
		-moz-box-shadow:-100px 10px 15px rgba(0,0,0,0.25);
	position:absolute;
	top:230px;
	left:113px;
	z-index:10;
	opacity:0.5;
	transform: rotate(-20deg);
		-webkit-transform: rotate(-20deg);
		-moz-transform: rotate(-20deg);
		-o-transform: rotate(-20deg);
	border-bottom-left-radius:40px;
		-webkit-border-bottom-left-radius:40px;
		-moz-border-radius-bottomleft:40px;
	border-top-left-radius:20px;
		-webkit-border-top-left-radius:20px;
		-moz-border-radius-topleft:20px;
}
#shadow_belt{
	width:40px;
	height:30px;
	box-shadow:-100px 10px 15px rgba(0,0,0,0);
		-webkit-box-shadow:-100px 10px 15px rgba(0,0,0,0.25);
		-moz-box-shadow:-100px 10px 15px rgba(0,0,0,0.25);
	position:absolute;
	top:240px;
	left:130px;
	z-index:10;
	border-bottom-left-radius:40px;
		-webkit-border-bottom-left-radius:40px;
		-moz-border-radius-bottomleft:40px;
	z-index:300;
}
#arm_left:not(\*|*), .arm_rewrite_left:not(\*|*){
	background:#07beea;
}
#arm_left, .arm_rewrite_left{
	background:#07beea\9;
	*background:#07beea;
	_background:#07beea;
}
#kiji{
	position:relative;
	top:-150px;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;doraemon&quot;&gt;
	&lt;div id=&quot;face&quot;&gt;
    	&lt;div id=&quot;head_light&quot;&gt;&lt;/div&gt;
    	&lt;div id=&quot;eyes&quot;&gt;
    	&lt;div class=&quot;eye eye_left&quot;&gt;&lt;/div&gt;
        	&lt;div class=&quot;black_eye black_left&quot;&gt;&lt;/div&gt;
      	&lt;div class=&quot;eye eye_right&quot;&gt;&lt;/div&gt;
        	&lt;div class=&quot;black_eye black_right&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div id=&quot;base&quot;&gt;
			&lt;div id=&quot;base_white&quot;&gt;&lt;/div&gt;
				&lt;div id=&quot;nose&quot;&gt;
					&lt;div id=&quot;nose_light&quot;&gt;&lt;/div&gt;
				&lt;/div&gt;
                &lt;div id=&quot;nose_line&quot;&gt;&lt;/div&gt;
                &lt;div id=&quot;mouth&quot;&gt;&lt;/div&gt;
                &lt;div id=&quot;mouth_rewrite&quot;&gt;&lt;/div&gt;
                &lt;div id=&quot;firefox_mouth&quot;&gt;&lt;/div&gt;
				&lt;div class=&quot;whiskers whi_right_top rotate160&quot;&gt;&lt;/div&gt;
				&lt;div class=&quot;whiskers whi_right&quot;&gt;&lt;/div&gt;
				&lt;div class=&quot;whiskers whi_right_bottom rotate20&quot;&gt;&lt;/div&gt;
				&lt;div class=&quot;whiskers whi_left_top rotate20&quot;&gt;&lt;/div&gt;
				&lt;div class=&quot;whiskers whi_left&quot;&gt;&lt;/div&gt;
				&lt;div class=&quot;whiskers whi_left_bottom rotate160&quot;&gt;&lt;/div&gt;
        &lt;/div&gt;
	&lt;/div&gt;
    &lt;div id=&quot;choker&quot;&gt;
    	&lt;div id=&quot;belt&quot;&gt;&lt;/div&gt;
    	&lt;div id=&quot;bell&quot;&gt;
       	  &lt;div id=&quot;bell_line&quot;&gt;&lt;/div&gt;
            &lt;div id=&quot;bell_circle&quot;&gt;&lt;/div&gt;
            &lt;div id=&quot;bell_under&quot;&gt;&lt;/div&gt;
		&lt;div id=&quot;bell_light&quot;&gt;&lt;/div&gt;
		&lt;/div&gt;
    &lt;/div&gt;
	&lt;div id=&quot;body&quot;&gt;
    &lt;div id=&quot;doutai&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;base_white2 doutai_center&quot;&gt;&lt;/div&gt;
        		&lt;div id=&quot;pocket&quot;&gt;
                	&lt;div id=&quot;circle&quot;&gt;&lt;/div&gt;
                    &lt;div id=&quot;circle_rewrite&quot;&gt;&lt;/div&gt;
                &lt;/div&gt;
	&lt;/div&gt;
	&lt;div id=&quot;hand_right&quot;&gt;
    	&lt;div id=&quot;arm_right&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;hand_circle hand_right&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;arm_rewrite_right&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
	&lt;div id=&quot;hand_left&quot;&gt;
    	&lt;div id=&quot;arm_left&quot;&gt;&lt;/div&gt;
		&lt;div class=&quot;hand_circle hand_left&quot;&gt;&lt;/div&gt;
	  &lt;div class=&quot;arm_rewrite_left&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
	&lt;div id=&quot;foot&quot;&gt;
    	&lt;div id=&quot;foot_left&quot;&gt;&lt;/div&gt;
        &lt;div id=&quot;foot_right&quot;&gt;&lt;/div&gt;
        &lt;div id=&quot;foot_rewrite&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
    	&lt;div id=&quot;shadow_doutai_arm&quot;&gt;&lt;/div&gt;
    	&lt;div id=&quot;shadow_doutai_left&quot;&gt;&lt;/div&gt;
    	&lt;div id=&quot;shadow_doutai_right&quot;&gt;&lt;/div&gt;
        &lt;div id=&quot;shadow_belt&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_AQ2Dus');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_AQ2Dus');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_AQ2Dus','runcode_AQ2Dus');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>17、CSS3QQ企鹅:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_RfDEi5">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;CSS3 QQ企鹅&lt;/title&gt;
&lt;!--by moondy --&gt;
&lt;style&gt;
body {margin:0; padding:0; background:#FFF;}
#qq {position:absolute; margin:50px 30%; width:500px;}
#face{
	position:relative;
	z-index:100;
	width:260px;
	height:200px;
	border-radius:400px 400px 280px 280px;
		-webkit-border-radius:400px 400px 280px 280px;
		-moz-border-radius:400px 400px 280px 280px;
	background:#000;
	background: -webkit-gradient(linear, right top, left bottom, from(#999) ,color-stop(0.20, #333), color-stop(0.73, #000),color-stop(0.95, #000), to(#000));
	background: -moz-linear-gradient(right top, #999,#333 20%, #000 73% ,#000 95% ,#000 155%);
	top:-15px;
}
#eyes{
	position:relative;
	top:-5px;
}
div.eye{
	position:absolute;
	border-radius: 100px;
		-webkit-border-radius: 100px;
		-moz-border-radius: 100px;
	width:50px;
	height:70px;
	z-index:20;
	background:#fff;
}
div.black_eye{
	position:absolute;
	width:15px;
	height:20px;
	border-radius:10px;
		-webkit-border-radius:10px;
		-moz-border-radius:10px;
	background:#333;
	z-index:21;
		-webkit-animation-name: cate;
		-webkit-animation-duration: 3s;
		-webkit-animation-timing-function: linear;
		-webkit-animation-iteration-count: 200;
}
div.black_left{
	top:95px;
	left:90px;
}
div.black_right{
	top:95px;
	left:160px;
}
div.eye_left{
	top:70px;
	left:65px;
}
div.eye_right{
	top:70px;
	left:140px;
}
.mouth_up {
	border-radius: 6px;
		-webkit-border-radius: 6px;
		-moz-border-radius: 6px;
	position:absolute;
	overflow:hidden;
	border-bottom:3px solid #F90;
	width:180px;
	height:22px;
	top:145px;
	left:40px;
}
.mouth_down {
	position:absolute;
	overflow:hidden;
	width:150px;
	height:15px;
	top:164px;
	left:55px;
}
.mouth_in {
	position:absolute;
	border-radius: 400px;
		-webkit-border-radius: 400px;
		-moz-border-radius: 400px;
	background:#F90;
	width:400px;
	height:400px;
}
.mouth_up div {
	top:0;
	left:-110px;
}
.mouth_down div {
	border:3px solid #000;
	bottom:0;
	left:-124px;
}
.scarf {
	position:relative;
	border:2px solid #000;
	z-index:90;
	width:256px;
	height:200px;
	border-radius:600px 600px 280px 280px;
		-webkit-border-radius:600px 600px 280px 280px;
		-moz-border-radius:600px 600px 280px 280px;
	background:#D00;
	top:-185px;
}
.main_body {
	position:relative;
	z-index:80;
	width:340px;
	height:260px;
	border-radius:500px 500px 400px 400px;
		-webkit-border-radius:500px 500px 400px 400px;
		-moz-border-radius:500px 500px 400px 400px;
	background:#000;
	top:-270px;
	left:-40px;
}
.hand_left {
	position:absolute;
	width:150px;
	height:45px;
	border-radius:120px 0 0 25px;
		-webkit-border-radius:120px 0 0 25px;
		-moz-border-radius:120px 0 0 25px;
	background:#000;
	transform: rotate(-35deg);
		-webkit-transform: rotate(-35deg);
		-moz-transform: rotate(-35deg);
		-o-transform: rotate(-35deg);
	top:75px;
	left:-75px;
}
.hand_right {
	position:absolute;
	width:150px;
	height:45px;
	border-radius:0 120px 25px 0;
		-webkit-border-radius:0 120px 25px 0;
		-moz-border-radius:0 120px 25px 0;
	background:#000;
	transform: rotate(35deg);
		-webkit-transform: rotate(35deg);
		-moz-transform: rotate(35deg);
		-o-transform: rotate(35deg);
	top:75px;
	left:270px;
}
.main_body .belly {
	position:absolute;
	width:300px;
	height:220px;
	border-radius:500px 500px 400px 400px;
		-webkit-border-radius:500px 500px 400px 400px;
		-moz-border-radius:500px 500px 400px 400px;
	background:#FFF;
	background: -webkit-gradient(linear, right top, left bottom, from(#FFF) ,color-stop(0.50, #FEFEFE), color-stop(0.73, #F2F2F2),color-stop(0.95, #EEE), to(#BBB));
	background: -moz-linear-gradient(right top, #FFF,#EEE 50%, #CCC 73% ,#999 95% ,#BBB 155%);
	top:30px;
	left:20px;
}
.main_body .belly .tie {
	position:absolute;
	width:35px;
	height:60px;
	border-radius:0 0 10px 10px;
		-webkit-border-radius:0 0 10px 10px;
		-moz-border-radius:0 0 10px 10px;
	border:2px solid #000;
	background:#D00;
	transform: rotate(10deg);
		-webkit-transform: rotate(10deg);
		-moz-transform: rotate(10deg);
		-o-transform: rotate(10deg);
	left:55px;
	top:48px;
}
.main_body .belly .tie .tie_line {
	position:absolute;
	width:2px;
	height:40px;
	background:#000;
	left:25px;
}
.foot_left {
	position:absolute;
	width:120px;
	height:45px;
	border-radius:160px 40px 100px 40px;
		-webkit-border-radius:160px 40px 100px 40px;
		-moz-border-radius:160px 40px 100px 40px;
	background:#F90;
	border:2px solid #000;
	top:370px;
	left:-40px;
}
.foot_right {
	position:absolute;
	width:120px;
	height:45px;
	border-radius:40px 160px 40px 100px;
		-webkit-border-radius:40px 160px 40px 100px;
		-moz-border-radius:40px 160px 40px 100px;
	background:#F90;
	border:2px solid #000;
	top:370px;
	left:176px;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;qq&quot;&gt;
  &lt;div id=&quot;face&quot;&gt;
  	&lt;div id=&quot;eyes&quot;&gt;
    	&lt;div class=&quot;eye eye_left&quot;&gt;&lt;/div&gt;
        &lt;div class=&quot;black_eye black_left&quot;&gt;&lt;/div&gt;
      	&lt;div class=&quot;eye eye_right&quot;&gt;&lt;/div&gt;
       	&lt;div class=&quot;black_eye black_right&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;mouth_up&quot;&gt;
      &lt;div class=&quot;mouth_in&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&quot;mouth_down&quot;&gt;
      &lt;div class=&quot;mouth_in&quot;&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;scarf&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;main_body&quot;&gt;
  	&lt;div class=&quot;hand_left&quot;&gt;&lt;/div&gt;
    &lt;div class=&quot;hand_right&quot;&gt;&lt;/div&gt;
    &lt;div class=&quot;belly&quot;&gt;
      &lt;div class=&quot;tie&quot;&gt;
        &lt;div class=&quot;tie_line&quot;&gt;&lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class=&quot;foot_left&quot;&gt;&lt;/div&gt;
  &lt;div class=&quot;foot_right&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_RfDEi5');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_RfDEi5');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_RfDEi5','runcode_RfDEi5');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>18、&#8230;:</strong><br />
续写。。。</p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=341" title="各种javascript实例效果 更新为2010.07.26">各种javascript实例效果 更新为2010.07.26</a> (4)</li><li><a href="http://www.hemin.cn/blog/?p=1270" title="各种jquery实例效果">各种jquery实例效果</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=259" title="面试题：纯CSS菜单和纯CSS选项卡">面试题：纯CSS菜单和纯CSS选项卡</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=44" title="各种浏览器css hack  更新为2009.8.7">各种浏览器css hack  更新为2009.8.7</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=1340" title="CSS查找匹配原理和简洁高效">CSS查找匹配原理和简洁高效</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1333" title="CSS清除浮动">CSS清除浮动</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1286" title="各种jQuery技巧">各种jQuery技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1133" title="腾讯Q组内部考核题">腾讯Q组内部考核题</a> (12)</li><li><a href="http://www.hemin.cn/blog/?p=1068" title="我推荐的书籍">我推荐的书籍</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1037" title="CSS框架">CSS框架</a> (5)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=339</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>各种javascript实例效果 更新为2010.07.26</title>
		<link>http://www.hemin.cn/blog/?p=341</link>
		<comments>http://www.hemin.cn/blog/?p=341#comments</comments>
		<pubDate>Mon, 26 Jul 2010 08:00:09 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[JS/JQuery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[实例]]></category>
		<category><![CDATA[收藏]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=341</guid>
		<description><![CDATA[新增实例：简单的原生态JavaScript缓动效果 这里收集和原创各种CSS+js实例效果。（为了工作需要和学习得更多） 1、二级菜单: i.横向 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62; &#60;title&#62;二级菜单横向(www.hemin.cn)&#60;/title&#62; &#60;script type=&#34;text/javascript&#34;&#62; /** *菜单的构造,需要绑定到onload */ startList = function() { if (document.all &#38;&#38; document.getElementById) { navRoot = document.getElementById(&#34;nav&#34;); for (i=0; i &#60; navRoot.childNodes.length; i++) { node = navRoot.childNodes[i]; if (node.nodeName==&#34;LI&#34;) { node.onmouseover=function() { this.className+=&#34; over&#34;; [...]]]></description>
			<content:encoded><![CDATA[<div style="font-size:14px;text-decoration:underline;">新增实例：<span style="color:#F00">简单的原生态JavaScript缓动效果</span></div>
<p>这里收集和原创各种CSS+js实例效果。（为了工作需要和学习得更多）</p>
<p><strong>1、二级菜单:</strong><br />
i.横向</p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_h5Ws6H">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;二级菜单横向(www.hemin.cn)&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
/**
*菜单的构造,需要绑定到onload
*/
startList = function() {
    if (document.all &amp;&amp; document.getElementById) {
        navRoot = document.getElementById(&quot;nav&quot;);
            for (i=0; i &lt; navRoot.childNodes.length; i++) {
                node = navRoot.childNodes[i];
                if (node.nodeName==&quot;LI&quot;) {
                    node.onmouseover=function() {
                    this.className+=&quot; over&quot;;
                }
                node.onmouseout=function() {
                    this.className=this.className.replace(&quot; over&quot;, &quot;&quot;);
                }
            }
        }
    }
}
window.onload = startList;
&lt;/script&gt;
&lt;style type=&quot;text/css&quot; media=&quot;all&quot;&gt;
html {
	min-width: 742px;
}
/*css基本规则*/
img {
	border:0;
}
p.access {
	display:none;
}
div#counters {
	display:none;
}/*计数器暂时不显示*/
a {
	text-decoration: none;
}
/* 主要布局 */
body {
	overflow:auto;
	text-align: center;
	margin: 0 auto;
	padding: 0;
	border: 0;
	background: #fff;
	color: #000;
	font: small/18px &quot;宋体&quot;, Verdana, Helvetica, sans-serif;
}
ul#nav, ul#nav ul {
	margin: 0 auto;
	text-align:left;
	padding: 0;
	list-style: none;
	background:#fff;
	z-index:99;
}
ul#nav {
	width:732px;
	display:block;
	height:24px;
	clear:both;
}
ul#nav li {
	position: relative;
	z-index:999;
	float:left;
}
ul#nav ul li {
	display:block;
}
ul#nav ul {
	width:100px;
	height:auto;
	position: absolute;
	text-align:left;
	left: 0px;
	display: none;
	border:solid 1px #697210;
}
/*当鼠标在子菜单和父菜单上时，父菜单的样式*/
ul#nav li.over a, ul#nav li:hover a {
	border-color:#E2144A;
	background: #fdd;
	font-weight:bold;
	color: #E2144A;
}
/*将子菜单的样式清除*/
ul#nav li.over ul a, ul#nav li:hover ul a {
	background:#fff;
	font-weight:normal;
	color:#777;
}
/*子菜单的hover样式*/
ul#nav li.over ul a:hover, ul#nav li:hover ul a:hover {
	background:#fff;
	font-weight:normal;
	color: #E2144A;
	background: #fdd;
	border-color:#E2144A;
	font-weight:bold;
}
/* Styles for Menu Items */
ul#nav a {
	font-size:14px;
	line-height:17px;
	display: block;
	padding:0 0 0 10px;
	width:78px;
	color: #777;
	height:17px;
	background: #fff;
	border-left:solid 1px #fff;
	border-top:solid 1px #fff;
	border-right:solid 1px #fff;
	border-bottom:solid 5px #697210;
}
ul#nav ul li {
	width:100px;
	border:0;
}
/* Fix IE. Hide from IE Mac \*/
* html ul#nav li {
	float: left;
	height: 17px;
}
* html ul#nav li a {
	height: 17px;
}
/* End */
ul#nav ul a {
	padding: 2px 0px 2px 10px;
	border:0;
	width:90px;
} /* Sub Menu Styles */
ul#nav li:hover ul, ul#nav li.over ul {
	display: block;
} /* The magic */
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;测试css菜单显示效果&lt;/p&gt;
&lt;!--菜单开始--&gt;
&lt;ul id=&quot;nav&quot;&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;文章&lt;/a&gt;
				&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;随笔&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;小说&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;诗&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;文摘&lt;/a&gt;&lt;/li&gt;
				&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;美图&lt;/a&gt;
				&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;漫画&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;摄影&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;CG作品&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;图+文&lt;/a&gt;&lt;/li&gt;
				&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;技术&lt;/a&gt;
				&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;在线工具&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;代码收集&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;实验室&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;技术文章&lt;/a&gt;&lt;/li&gt;
				&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;网站收藏夹&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;读书笔记&lt;/a&gt;
				&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;哲学&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;小说&lt;/a&gt;&lt;/li&gt;
				&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;日记&lt;/a&gt;
				&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;生活&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;工作&lt;/a&gt;&lt;/li&gt;
				&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;计划&lt;/a&gt;
				&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;计划要做的事&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;计划要买的&lt;/a&gt;&lt;/li&gt;
				&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;其他&lt;/a&gt;
				&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;关于本站&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;留言&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;友情链接&lt;/a&gt;&lt;/li&gt;
				&lt;/ul&gt;
		&lt;/li&gt;
&lt;/ul&gt;
&lt;!--菜单结束--&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_h5Ws6H');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_h5Ws6H');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_h5Ws6H','runcode_h5Ws6H');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><span id="more-341"></span><br />
ii.竖向</p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_15luSE">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt;二级菜单竖向(www.hemin.cn)&lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html&quot; charset=&quot;utf-8&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; &gt;
// JavaScript Document
startList = function() {
	if (document.all &amp;&amp; document.getElementById) {
		navRoot = document.getElementById(&quot;nav&quot;);
		for (i=0; i &lt; navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName==&quot;LI&quot;) {
				node.onmouseover=function() {
					this.className+=&quot; over&quot;;
					}
					node.onmouseout=function() {
						this.className=this.className.replace(&quot; over&quot;, &quot;&quot;);
						}
				}
		}
	}
}
window.onload=startList;
&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
body {
	font: normal 11px verdana;
	}
ul {
	margin: 0;
	padding: 0;
	list-style: none;
	width: 150px; /* Width of Menu Items */
	border-bottom: 1px solid #ccc;
	}
ul li {
	position: relative;
	}
li ul {
	position: absolute;
	left: 149px; /* Set 1px less than menu width */
	top: 0;
	display: none;
	}
/* Styles for Menu Items */
ul li a {
	display: block;
	text-decoration: none;
	color: #777;
	background: #fff; /* IE6 Bug */
	padding: 5px;
	border: 1px solid #ccc;
	border-bottom: 0;
	}
/* Fix IE. Hide from IE Mac \*/
* html ul li { float: left; height: 1%; }
* html ul li a { height: 1%; }
/* End */
ul li a:hover { color: #E2144A; background: #f9f9f9; } /* Hover Styles */
li ul li a { padding: 2px 5px; } /* Sub Menu Styles */
li:hover ul, li.over ul { display: block; } /* The magic */
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;ul id=&quot;nav&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;History&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Team&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Offices&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Services&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Web Design&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Internet Marketing&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Hosting&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Domain Names&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Broadband&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Contact Us&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;United Kingdom&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;France&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;USA&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Australia&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_15luSE');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_15luSE');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_15luSE','runcode_15luSE');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>2、自定义容器和字体大小:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_Hb88ZA">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;title&gt;自定义容器和字体大小(www.hemin.cn)&lt;/title&gt;
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=iso-8859-1&quot; /&gt;
&lt;meta name=&quot;author&quot; content=&quot;The Man in Blue&quot; /&gt;
&lt;meta name=&quot;robots&quot; content=&quot;all&quot; /&gt;
&lt;meta name=&quot;MSSmartTagsPreventParsing&quot; content=&quot;true&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;
&lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;
&lt;style type=&quot;text/css&quot; media=&quot;all&quot;&gt;
body
{
	margin: 1em;
	text-align: center;
	font-family: Arial, Helvetica, sans-serif;
}
body *
{
	margin: 0;
}
#content
{
	padding: 1em;
	background-color: #BBDDFF;
	background-image: url(column_bg.gif);
	background-repeat: repeat-y;
	background-position: 30em 0;
	text-align: left;
}
#content p
{
	margin-bottom: 1em;
}
#footer
{
	margin-top: 1em;
	padding: 1em;
	background-color: #0066CC;
	text-align: left;
}
#footer a
{
	color: #FFFFFF;
}
#header
{
	margin-bottom: 1em;
	padding: 1em;
	background-color: #0066CC;
	color: #FFFFFF;
	text-align: left;
}
#leftContent
{
	padding-right: 10em;
}
#options
{
	margin-bottom: 1em;
	text-align: right;
}
#options a
{
	color: #000000;
}
#rightContent
{
	float: right;
	width: 8em;
}
#widthContainer
{
	font-size: 0.8em;
	width: 40em;
	margin: auto;
}
.clearer
{
	clear: both;
}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
function scaleWidth()
{
	var optimalLineLength = &quot;35em&quot;;
	var extraAccounting = &quot;12em&quot;;
	var minimumTextHeight = &quot;10px&quot;;
	var windowWidth = document.body.clientWidth;
	var optimalSize = windowWidth / (parseInt(optimalLineLength) + parseInt(extraAccounting));
	if (optimalSize &gt;= parseInt(minimumTextHeight))
	{
		document.body.style.fontSize = optimalSize + &quot;px&quot;;
	}
	else
	{
		document.body.style.fontSize = parseInt(minimumTextHeight) + &quot;px&quot;;
	}
	return true;
}
function textSize(size)
{
	var theContainer = document.getElementById(&quot;widthContainer&quot;);
	var increment = 0.1
	var currentSize = parseFloat(document.getElementById(&quot;widthContainer&quot;).style.fontSize);
	if (!currentSize)
	{
		currentSize = 0.8;
	}
	if (size == &quot;smaller&quot;)
	{
		theContainer.style.fontSize = (currentSize - increment) + &quot;em&quot;;
	}
	else
	{
		theContainer.style.fontSize = (currentSize + increment) + &quot;em&quot;;
	}
	return true;
}
--&gt;
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload=&quot;scaleWidth();&quot; onresize=&quot;scaleWidth();&quot;&gt;
	&lt;div id=&quot;widthContainer&quot;&gt;
		&lt;div id=&quot;options&quot;&gt;
			&lt;a href=&quot;#&quot; onclick=&quot;textSize('smaller'); return false;&quot;&gt;Text smaller&lt;/a&gt; |
			&lt;a href=&quot;#&quot; onclick=&quot;textSize('bigger'); return false;&quot;&gt;Text bigger&lt;/a&gt;
		&lt;/div&gt;
&lt;!-- END options --&gt;
		&lt;div id=&quot;header&quot;&gt;
			&lt;h1&gt;Browser-width defined font size&lt;/h1&gt;
		&lt;/div&gt;
&lt;!-- END header --&gt;
		&lt;div id=&quot;content&quot;&gt;
			&lt;div id=&quot;rightContent&quot;&gt;
				&lt;p&gt;
					Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed lobortis ullamcorper augue. Praesent vel felis vitae purus ornare pretium. Nullam porta sollicitudin lectus. Integer non arcu eu neque tincidunt tincidunt. Nullam sapien arcu, ullamcorper sed, hendrerit in, rutrum in, nibh. Aliquam sed enim. Cras rhoncus ullamcorper justo. Aenean quam dolor, consectetuer sed, dapibus quis, iaculis id, diam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut lacinia velit ac elit. Etiam id nulla. Phasellus at arcu ac mauris hendrerit ullamcorper. Quisque posuere sodales risus. Sed nunc nibh, egestas a, blandit eget, facilisis vel, dolor. Cras metus urna, feugiat et, iaculis quis, lacinia a, elit. Etiam enim. Maecenas viverra, est non tincidunt euismod, diam urna volutpat mi, in luctus pede ante sit amet risus.
				&lt;/p&gt;
			&lt;/div&gt;
&lt;!-- END rightContent --&gt;
			&lt;div id=&quot;leftContent&quot;&gt;
				&lt;p&gt;
					Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed lobortis ullamcorper augue. Praesent vel felis vitae purus ornare pretium. Nullam porta sollicitudin lectus. Integer non arcu eu neque tincidunt tincidunt. Nullam sapien arcu, ullamcorper sed, hendrerit in, rutrum in, nibh. Aliquam sed enim. Cras rhoncus ullamcorper justo. Aenean quam dolor, consectetuer sed, dapibus quis, iaculis id, diam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Ut lacinia velit ac elit. Etiam id nulla. Phasellus at arcu ac mauris hendrerit ullamcorper. Quisque posuere sodales risus. Sed nunc nibh, egestas a, blandit eget, facilisis vel, dolor. Cras metus urna, feugiat et, iaculis quis, lacinia a, elit. Etiam enim. Maecenas viverra, est non tincidunt euismod, diam urna volutpat mi, in luctus pede ante sit amet risus.
				&lt;/p&gt;
				&lt;p&gt;
					Nulla metus. Ut sodales, tortor nec sollicitudin convallis, diam diam vulputate ligula, lobortis tincidunt urna purus at urna. Pellentesque laoreet. Nulla et dolor. Praesent vestibulum quam convallis neque. Praesent sit amet odio a dui iaculis dignissim. In vel nunc a tellus vulputate pellentesque. Maecenas bibendum. Donec mi nibh, euismod in, iaculis a, eleifend et, enim. In eget lectus vitae pede nonummy elementum. Mauris accumsan, lacus ut euismod varius, odio neque egestas quam, non aliquam velit purus et purus. Vestibulum at elit nec felis suscipit pulvinar. Suspendisse at enim quis lacus mattis condimentum. Proin arcu arcu, imperdiet vitae, aliquam non, congue id, ipsum.
				&lt;/p&gt;
				&lt;p&gt;
					Aliquam eu dolor nec risus luctus faucibus. Aenean condimentum, tortor in blandit cursus, dolor magna sagittis orci, vel vehicula dolor ante at lacus. Donec vel felis in enim aliquam molestie. Sed non velit id velit pulvinar consequat. Mauris luctus. Phasellus faucibus turpis nec purus. Mauris eget ante. Donec orci enim, luctus eu, posuere at, luctus quis, pede. In in lectus. Quisque blandit, ipsum eget tincidunt scelerisque, mauris ante accumsan erat, quis congue odio erat vitae diam. Donec ut felis fermentum sem viverra pulvinar. Sed neque lorem, adipiscing ut, placerat a, ornare et, dolor. Vestibulum pretium vehicula nibh. Etiam feugiat, ligula sed pulvinar fringilla, eros arcu placerat urna, nec eleifend nisl leo sit amet urna. Suspendisse quis augue ut nibh venenatis nonummy. Nunc ut augue. In fermentum, neque eget eleifend rutrum, nulla lorem fermentum massa, eu cursus lectus mi id libero.
				&lt;/p&gt;
				&lt;p&gt;
					Nam congue ligula quis magna. Vivamus porttitor nunc non dui. Aliquam posuere dapibus tortor. Quisque facilisis, quam in semper luctus, lacus dolor gravida massa, ultrices consectetuer risus arcu nec nibh. Nulla facilisi. In a eros id eros lobortis ultrices. Vivamus sit amet neque eu magna venenatis nonummy. Pellentesque consequat. Etiam ut ipsum. Nulla consectetuer est vel quam.
				&lt;/p&gt;
				&lt;p&gt;
					Integer eu diam vitae augue sollicitudin congue. Praesent vulputate pede vel velit. Maecenas dapibus tempus lacus. Quisque lectus metus, pretium ac, mollis nec, dignissim quis, mi. Aliquam purus risus, pharetra eget, condimentum ut, blandit sit amet, leo. Suspendisse iaculis purus sed tellus. Nunc sem justo, porttitor ut, pretium eu, hendrerit eu, nunc. Vivamus sit amet neque in est venenatis faucibus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam rhoncus, eros id ultrices facilisis, pede ligula dignissim eros, sit amet tempus risus urna sed nibh. Sed massa eros, dapibus tristique, blandit et, molestie sed, enim. Phasellus leo. Integer vestibulum volutpat enim. Duis pulvinar ligula. Pellentesque luctus velit a justo. Quisque volutpat, diam quis varius commodo, neque elit dictum tortor, quis aliquet felis risus vitae wisi. Aliquam bibendum, elit ut gravida vehicula, orci turpis auctor dolor, nec tristique tortor dolor eget ipsum.
				&lt;/p&gt;
			&lt;/div&gt;
&lt;!-- END leftContent --&gt;
			&lt;div class=&quot;clearer&quot;&gt;
			&lt;/div&gt;
		&lt;/div&gt;
&lt;!-- END content --&gt;
		&lt;div id=&quot;footer&quot;&gt;
			&lt;a href=&quot;http://www.themaninblue.com/writing/perspective/2003/12/22/&quot;&gt;Back to the explanation&lt;/a&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;!-- END widthContainer --&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_Hb88ZA');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_Hb88ZA');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_Hb88ZA','runcode_Hb88ZA');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>3、预载模拟:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_I9Jpfo">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; lang=&quot;zh-CN&quot; xml:lang=&quot;zh-CN&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;预载模拟(www.hemin.cn)&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
.load_ { width:200px; height:40px; padding:20px 50px; margin:20px; font-size:9pt; background:#eee; }
.load_ p { margin-bottom:8px; height:12px; line-height:12px; border:1px solid; border-color:#fff #000 #000 #fff; padding:4px 2px 2px; text-align:right; font-size:7pt; font-family:Lucida Sans!important; color:#333; background:#ff0; }
&lt;/style&gt;
&lt;head&gt;
&lt;body&gt;
&lt;div class=&quot;load_&quot;&gt;
&lt;p style=&quot;width:1%;&quot; id=&quot;load_&quot;&gt;&lt;/p&gt;
正在载入，请稍后...
&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function $(id,tag){if(!tag){return document.getElementById(id);}else{return document.getElementById(id).getElementsByTagName(tag);}}
function loads_(obj,s){
	var objw=$(obj).style.width;
	if(objw!=&quot;101%&quot;){
		if(!s){var s=0;}
		$(obj).innerHTML=objw;
		$(obj).style.width=s+&quot;%&quot;;
		s++;
		setTimeout(function (){loads_(obj,s)},50);
	}
	else{
		$(obj).innerHTML=&quot;完毕!!!!&quot;;
	}
}
loads_(&quot;load_&quot;);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_I9Jpfo');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_I9Jpfo');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_I9Jpfo','runcode_I9Jpfo');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>4、放大缩小容器：仿动画:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_UkyMhc">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; lang=&quot;zh-CN&quot; xml:lang=&quot;zh-CN&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;放大缩小容器：仿动画 (www.hemin.cn)&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{margin:0;padding:0;}
body { padding:1em; }
h2 { font-size:2em; }
div { display:inline-block; width:10em; padding:.5em; margin-bottom:1em; overflow:hidden; background:#eee; text-align:center; font-size:1em; }
p#text { position:absolute; right:10px; top:10px; }
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p id=&quot;text&quot;&gt;&lt;/p&gt;
&lt;div id=&quot;box1&quot; onmouseover=&quot;pr_box('box1',150);&quot; onmouseout=&quot;pr_box('box1',100);&quot;&gt;
	&lt;h2&gt;标题&lt;/h2&gt;
	&lt;p&gt;测试鼠标滑动效果&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;box2&quot; onmouseover=&quot;pr_box('box2',150);&quot; onmouseout=&quot;pr_box('box2',100);&quot;&gt;
	&lt;h2&gt;标题&lt;/h2&gt;
	&lt;p&gt;测试鼠标滑动效果&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;box3&quot; onmouseover=&quot;pr_box('box3',150);&quot; onmouseout=&quot;pr_box('box3',100);&quot;&gt;
	&lt;h2&gt;标题&lt;/h2&gt;
	&lt;p&gt;测试鼠标滑动效果&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&quot;box4&quot; onmouseover=&quot;pr_box('box4',150);&quot; onmouseout=&quot;pr_box('box4',100);&quot;&gt;
	&lt;h2&gt;标题&lt;/h2&gt;
	&lt;p&gt;测试鼠标滑动效果&lt;/p&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function getDefaultStyle(obj,attribute){ //返回最终样式函数，兼容IE和DOM，设置参数：元素对象、样式特性
    return obj.currentStyle?obj.currentStyle[attribute]:document.defaultView.getComputedStyle(obj,false)[attribute];
}
function pr_box(id,e){
	clearInterval(document.getElementById(id).maxmin);
	var obj=document.getElementById(id);
	var cfont=getDefaultStyle(obj,&quot;fontSize&quot;);// 得到默认的大小:附单位
	var cp=cfont.replace(/[0-9]|[\.]/g,&quot;&quot;);// 得到默认的单位
	var fsize=parseFloat(cfont);// 得到默认的大小数值
	var s=10;// 运动速度
	if(!obj.fsizeTmpe){// 存储默认大小数值
		obj.fsizeTmpe=fsize;
		}
	if(!objfont){// 如果没有设置当前大小，则赋予其默认大小
		obj.style.fontSize = cfont;
	}
	var e = obj.fsizeTmpe*e/100;// 需要改变到的大小数值
	var objfont = parseFloat(obj.style.fontSize);// 得到当前的大小
	if(e &lt; obj.fsizeTmpe){obj.maxmin = setInterval(function(){pr_min(obj,e,cp)},s);}
	if(e &gt; obj.fsizeTmpe){obj.maxmin = setInterval(function(){pr_max(obj,e,cp)},s);}
	if(e == obj.fsizeTmpe){
		if(objfont &lt; obj.fsizeTmpe){
			obj.maxmin = setInterval(function(){pr_max(obj,obj.fsizeTmpe,cp)},s);
		}
		if(objfont &gt; obj.fsizeTmpe){
			obj.maxmin = setInterval(function(){pr_min(obj,obj.fsizeTmpe,cp)},s);
		}
	}
}
function pr_max(obj,e,cp){
	if(!obj.fs){
		obj.fs=obj.style.fontSize;
	}
	var objfont=parseFloat(obj.fs);
	if(e &gt; objfont){
	//document.getElementById(&quot;text&quot;).innerHTML+=&quot;放大 - 原始值：&quot;+objfont+&quot; + 递增值：&quot;+e/10+&quot;&lt;br /&gt;&quot;;
		obj.fs = objfont+e/10+cp;
		obj.style.fontSize = obj.fs;
	}
	else if(e &lt; objfont){
		obj.fs = e+cp;
		obj.style.fontSize = obj.fs;
	}
	else{clearInterval(obj.maxmin);}
}
function pr_min(obj,e,cp){
	if(!obj.fs){
		obj.fs=obj.style.fontSize;
	}
	var objfont=parseFloat(obj.fs);
	if(e &lt; objfont){
	//document.getElementById(&quot;text&quot;).innerHTML+=&quot;缩小 - 原始值：&quot;+objfont+&quot; - 递减值：&quot;+e/10+&quot;&lt;br /&gt;&quot;;
		obj.fs = objfont-e/10+cp;
		obj.style.fontSize = obj.fs;
	}
	else if(e &gt; objfont){
		obj.fs = e+cp;
		obj.style.fontSize = obj.fs;
	}
	else{clearInterval(obj.maxmin);}
}
&lt;/script&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_UkyMhc');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_UkyMhc');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_UkyMhc','runcode_UkyMhc');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>转：<a href="http://blog.pr1984.com/article.asp?id=87" target="_blank">http://blog.pr1984.com/article.asp?id=87</a></p>
<p><strong>5、DIV显示隐藏效果:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_eZkPeE">
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;DIV显示隐藏效果(www.hemin.cn)&lt;/title&gt;
&lt;style&gt;
* { margin:0; padding:0;}
body { text-align:center; font:75% Verdana, Arial, Helvetica, sans-serif;}
h1 { font:125% Arial, Helvetica, sans-serif; text-align:left; font-weight:bolder; background:#333;  padding:3px; display:block; color:#99CC00}
.class1 { width:40%; background:#CCC; position:relative; margin:0 auto; padding:5px;}
span { position:absolute; right:10px; top:8px; cursor:pointer; color:yellow;}
p { text-align:left; line-height:20px; background:#333; padding:3px; margin-top:5px; color:#99CC00}
#class1content { height:300px;overflow:hidden}
&lt;/style&gt;
&lt;script&gt;
function $(element){
	return element = document.getElementById(element);
}
function $D(){
	var d=$('class1content');
	var h=d.offsetHeight;
	var maxh=300;
	function dmove(){
		h += 50; //设置层展开的速度
		if(h &gt;= maxh){
			d.style.height='300px';
			clearInterval(iIntervalId);
			}else{
				d.style.display='block';
				d.style.height=h+'px';
				}
	}
	iIntervalId=setInterval(dmove,2);
}
function $D2(){
	var d=$('class1content');
	var h=d.offsetHeight;
	var maxh=300;
	function dmove(){
		h-=50;//设置层收缩的速度
		if(h&lt;=0){
			d.style.display='none';
			clearInterval(iIntervalId);
			}else{
				d.style.height=h+'px';
				}
		}
		iIntervalId=setInterval(dmove,2);
}
function $use(){
	var d=$('class1content');
	var sb=$('stateBut');
	if(d.style.display=='none'){
		$D();
		sb.innerHTML='展开';
		}else{
			$D2();
			sb.innerHTML='收缩';
			}
	}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;class1&quot;&gt;
&lt;h1&gt;Alone展开隐藏效果&lt;/h1&gt;
&lt;span id=&quot;stateBut&quot; onClick=&quot;$use()&quot;&gt;展开&lt;/span&gt;
&lt;p id=&quot;class1content&quot;&gt;小蜗牛问妈妈：为什么我们从生下来，就要背负这个又硬又重的壳呢？&lt;br /&gt;
妈妈：因为我们的身体没有骨骼的支撑，只能爬，又爬不快。所以要这个壳的保护！&lt;br /&gt;
小蜗牛：毛虫姊姊没有骨头，也爬不快，为什么她却不用背这个又硬又重的壳呢？ &lt;br /&gt;
妈妈：因为毛虫姊姊能变成蝴蝶，天空会保护她啊。 &lt;br /&gt;
小蜗牛：可是蚯蚓弟弟也没骨头爬不快，也不会变成蝴蝶他什么不背这个又硬又重的壳呢？ &lt;br /&gt;
妈妈：因为蚯蚓弟弟会钻土, 大地会保护他啊。 &lt;br /&gt;
小蜗牛哭了起来：我们好可怜，天空不保护，大地也不保护。 &lt;br /&gt;
蜗牛妈妈安慰他：所以我们有壳啊！我们不靠天，也不靠地，我们靠自己。&lt;/p&gt;
&lt;/div&gt;
&lt;/body&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_eZkPeE');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_eZkPeE');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_eZkPeE','runcode_eZkPeE');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>6、PNG-24 For ie6透明:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_cNaBe2">
&lt;!DOCTYPE html public &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;meta name=&quot;Keywords&quot; content=&quot;&quot; /&gt;
&lt;meta name=&quot;Description&quot; content=&quot;&quot; /&gt;
&lt;title&gt;PNG-24 For ie6透明(www.hemin.cn)&lt;/title&gt;
&lt;!--[if IE 6]&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.hemin.cn/demo/DD_Png/DD_belatedPNG_0.0.8a.js&quot; &gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot;&gt;
	DD_belatedPNG.fix('.trans,.box a:hover');
	&lt;/script&gt;
	&lt;![endif]--&gt;
&lt;style type=&quot;text/css&quot;&gt;
.example {
	width:600px;
	height:400px;
	float:left;
	background:url(http://www.hemin.cn/demo/DD_Png/bg.jpg) no-repeat 0 0;
	position:relative;
}
.trans {
	position:absolute;
	width:200px;
	height:50px;
	top:200px;
	left:200px;
	color:#fff;
	font-size:18px;
	font-family:Georgia;
	background:url(http://www.hemin.cn/demo/DD_Png/trans.png) repeat;
}
.box {
	position:absolute;
	top:100px;
	left:200px;
}
.box a {
	display:block;
	width:80px;
	height:80px;
	color:#fff;
	font-size:12px;
}
.box a:hover {
	background:url(http://www.hemin.cn/demo/DD_Png/boxbg.png) no-repeat left top;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;example&quot;&gt;
		&lt;div class=&quot;trans&quot;&gt;Damn IE6!这是repeat的PNG&lt;/div&gt;
		&lt;div class=&quot;box&quot;&gt;&lt;a href=&quot;&quot;&gt;请把鼠标移到这里 测试a:hover&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_cNaBe2');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_cNaBe2');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_cNaBe2','runcode_cNaBe2');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>原文：<a href="http://dillerdesign.com/experiment/DD_belatedPNG/" target="_blank">http://dillerdesign.com/experiment/DD_belatedPNG/</a></p>
<p><strong>7、选项卡:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_RBs9_t">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; lang=&quot;zh-CN&quot; xml:lang=&quot;zh-CN&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;选项卡(www.hemin.cn)&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
&lt;!--
* { margin:0; padding:0; font-size:12px; font-weight:normal; }
.jj  { font-weight:bolder!important; }
.box { border-top-color:#c00!important; }
.pr { color:#060!important; }
#tab01 { position:relative; width:336px; height:88px; padding-top:15px; margin:50px; overflow:hidden; }
#tab01 h3 { position:relative; z-index:2; float:left; height:14px; padding:0 7px 0 8px; margin-left:-1px; border-left:solid 1px #ccc; border-right:solid 1px #fff; text-align:center; background:#fff; cursor:pointer; }
#tab01 h3.up { height:18px; padding:5px 7px 0 7px; margin:-6px 0 0 0; border:solid #ccc; border-width:1px 1px 0; color:#c00; }
#tab01 div { display:none; position:absolute; left:0; top:32px; z-index:1; width:324px; height:54px; padding:5px; border:solid 1px #ccc; color:#666; }
#tab01 div.up { display:block; }
#tab02 { position:relative; width:200px; margin:50px; border:solid #ccc; border-width:0 1px 1px; }
#tab02 h4 { height:18px; line-height:18px; border:solid #ccc; border-width:1px 0; margin-bottom:-1px; text-align:center; background:#f6f6f6; cursor:pointer; }
#tab02 h4.up { color:#c00; }
#tab02 ol { display:none; height:54px; padding:5px; color:#666; }
#tab02 ol.up { display:block; }
#tab03 { position:relative; width:100px; margin:50px; }
#tab03 h3 { position:relative; z-index:1; height:16px; padding-top:4px; margin-bottom:-1px; border:solid #ccc; border-width:1px 0 1px 1px; text-align:center; font-family:宋体; background:#eee; cursor:pointer; }
#tab03 h3.up { z-index:3; color:#c00; background:#fff; }
#tab03 div.tab { display:none; position:absolute; left:99px; top:0; z-index:2; width:300px; height:200px; padding:5px; border:solid 1px #ccc; color:#666; }
#tab03 div.tab.up { display:block; }
--&gt;
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;tab01&quot;&gt;
	&lt;h3&gt;首页&lt;/h3&gt;
		&lt;div class=&quot;jj&quot;&gt;&lt;p&gt;嘿嘿，无视div原始class值。&lt;/p&gt;&lt;/div&gt;
	&lt;h3 class=&quot;pr&quot;&gt;测试&lt;/h3&gt;
		&lt;div&gt;&lt;p&gt;继续无视h3原始class值。&lt;/p&gt;&lt;/div&gt;
	&lt;h3&gt;无聊&lt;/h3&gt;
		&lt;div&gt;&lt;p&gt;h3没有值也可以～&lt;/p&gt;&lt;/div&gt;
	&lt;h3 class=&quot;box&quot;&gt;傻蛋&lt;/h3&gt;
		&lt;div&gt;&lt;p&gt;div没有值一样可以～&lt;/p&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;tab02&quot;&gt;
	&lt;h4&gt;首页&lt;/h4&gt;
		&lt;ol class=&quot;pr&quot;&gt;&lt;li&gt;嘿嘿，无视容器原始class值。&lt;/li&gt;&lt;/ol&gt;
	&lt;h4 class=&quot;box&quot;&gt;测试&lt;/h4&gt;
		&lt;ol&gt;&lt;li&gt;继续无视h3原始class值。&lt;/li&gt;&lt;/ol&gt;
	&lt;h4&gt;无聊&lt;/h4&gt;
		&lt;ol&gt;&lt;li&gt;h3没有值也可以～&lt;/li&gt;&lt;/ol&gt;
	&lt;h4 class=&quot;bb&quot;&gt;傻蛋&lt;/h4&gt;
		&lt;ol&gt;&lt;li&gt;div没有值一样可以～&lt;/li&gt;&lt;/ol&gt;
&lt;/div&gt;
&lt;div id=&quot;tab03&quot;&gt;
	&lt;h3&gt;首页&lt;/h3&gt;
		&lt;div class=&quot;tab&quot;&gt;&lt;p&gt;嘿嘿，无视h3原始class值。&lt;/p&gt;&lt;/div&gt;
	&lt;h3&gt;测试&lt;/h3&gt;
		&lt;div class=&quot;tab wushi&quot;&gt;&lt;p&gt;继续无视div原始class值。&lt;/p&gt;&lt;/div&gt;
	&lt;h3&gt;无聊&lt;/h3&gt;
		&lt;div class=&quot;tab&quot;&gt;&lt;p&gt;h3没有值也可以～&lt;/p&gt;&lt;/div&gt;
	&lt;h3 class=&quot;box&quot;&gt;傻蛋&lt;/h3&gt;
		&lt;div class=&quot;tab tab123&quot;&gt;&lt;p&gt;class值相似一样也可以～&lt;/p&gt;&lt;div&gt;&lt;p&gt;指定class后，即时再多一个div也行。&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
function Pid(id,tag){
	if(!tag){
		return document.getElementById(id);
		}
	else{
		return document.getElementById(id).getElementsByTagName(tag);
		}
}
// 选项卡 - [id],[hx=标题],[box=容器标记],[iClass=容器样式],[s=事件],[pr=序列]
function tab(id,hx,box,iClass,s,pr){
	var hxs=Pid(id,hx);
	var boxs=Pid(id,box);
	if(!iClass){ // 如果不指定class，则：
		boxsClass=boxs; // 直接使用box作为容器
	}
	else{ // 如果指定class，则：
		var boxsClass = [];
		for(i=0;i&lt;boxs.length;i++){
			if(boxs[i].className.match(/\btab\b/)){// 判断容器的class是否匹配
				boxsClass.push(boxs[i]);
			}
		}
	}
	if(!pr){ // 如果不指定预展开容器，则：
		go_to(0); // 默认展开序列
		yy();
	}
	else {
		go_to(pr);
		yy();
	}
	function yy(){
		for(var i=0;i&lt;hxs.length;i++){
			hxs[i].temp=i;
			if(!s){// 如果不指定事件，则：
				s=&quot;onmouseover&quot;; // 使用默认事件
				hxs[i][s]=function(){
					go_to(this.temp);
				}
			}
			else{
				hxs[i][s]=function(){
					go_to(this.temp);
				}
			}
		}
	}
	function go_to(pr){
		for(var i=0;i&lt;hxs.length;i++){
			if(!hxs[i].tmpClass){
				hxs[i].tmpClass=hxs[i].className+=&quot; &quot;;
				boxsClass[i].tmpClass=boxsClass[i].className+=&quot; &quot;;
			}
			if(pr==i){
				hxs[i].className+=&quot; up&quot;; // 展开状态：标题
				boxsClass[i].className+=&quot; up&quot;; // 展开状态：容器
			}
			else {
				hxs[i].className=hxs[i].tmpClass;
				boxsClass[i].className=boxsClass[i].tmpClass;
			}
		}
	}
}
tab(&quot;tab01&quot;,&quot;h3&quot;,&quot;div&quot;,&quot;&quot;,&quot;onclick&quot;,2); // 使用div为容器，指定事件，指定序列。
tab(&quot;tab02&quot;,&quot;h4&quot;,&quot;ol&quot;); // 使用ol为容器，默认事件，默认序列。
tab(&quot;tab03&quot;,&quot;h3&quot;,&quot;div&quot;,&quot;tab&quot;); // 使用div.tab为容器，默认事件，默认序列。
//--&gt;
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_RBs9_t');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_RBs9_t');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_RBs9_t','runcode_RBs9_t');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>转：<a href="http://blog.pr1984.com/article.asp?id=71" target="_blank">http://blog.pr1984.com/article.asp?id=71</a></p>
<p><strong>8、Table Stripes and Row Locking.-(checkbox) :</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_ANvRgY">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;title&gt;Table Stripes and Row Locking(www.hemin.cn)&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
body	{background:#fff;}
h1		{font:bold 20px/26px Arial;}
p, li, td	{font:normal 12px/17px Arial;}
table	{border:0;border-collapse:collapse;}
td		{padding:4px;}
th		{font:bold 12px/17px Arial;text-align:left;padding:4px;border-bottom:1px solid #333;}
tr.odd	{background:#e4dcd9;}
tr.highlight	{background:#BDA9A2;}
tr.selected		{background:#4a1200;color:#fff;}
td+td+td {text-align:right;}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
function addClass(element,value) {
  if (!element.className) {
    element.className = value;
  } else {
    newClassName = element.className;
    newClassName+= &quot; &quot;;
    newClassName+= value;
    element.className = newClassName;
  }
}
function stripeTables() {
	var tables = document.getElementsByTagName(&quot;table&quot;);
	for (var m=0; m&lt;tables.length; m++) {
		if (tables[m].className == &quot;pickme&quot;) {
			var tbodies = tables[m].getElementsByTagName(&quot;tbody&quot;);
			for (var i=0; i&lt;tbodies.length; i++) {
				var odd = true;
				var rows = tbodies[i].getElementsByTagName(&quot;tr&quot;);
				for (var j=0; j&lt;rows.length; j++) {
					if (odd == false) {
						odd = true;
					} else {
						addClass(rows[j],&quot;odd&quot;);
						odd = false;
					}
				}
			}
		}
	}
}
function highlightRows() {
  if(!document.getElementsByTagName) return false;
  	var tables = document.getElementsByTagName(&quot;table&quot;);
	for (var m=0; m&lt;tables.length; m++) {
		if (tables[m].className == &quot;pickme&quot;) {
			  var tbodies = tables[m].getElementsByTagName(&quot;tbody&quot;);
			  for (var j=0; j&lt;tbodies.length; j++) {
				 var rows = tbodies[j].getElementsByTagName(&quot;tr&quot;);
				 for (var i=0; i&lt;rows.length; i++) {
					   rows[i].oldClassName = rows[i].className
					   rows[i].onmouseover = function() {
						  if( this.className.indexOf(&quot;selected&quot;) == -1)
							 addClass(this,&quot;highlight&quot;);
					   }
					   rows[i].onmouseout = function() {
						  if( this.className.indexOf(&quot;selected&quot;) == -1)
							 this.className = this.oldClassName
					   }
				 }
			  }
		}
	}
}
function selectRowCheckbox(row) {
	var checkbox = row.getElementsByTagName(&quot;input&quot;)[0];
	if (checkbox.checked == true) {
		checkbox.checked = false;
	} else
	if (checkbox.checked == false) {
		checkbox.checked = true;
	}
}
function lockRow() {
  	var tables = document.getElementsByTagName(&quot;table&quot;);
	for (var m=0; m&lt;tables.length; m++) {
		if (tables[m].className == &quot;pickme&quot;) {
				var tbodies = tables[m].getElementsByTagName(&quot;tbody&quot;);
				for (var j=0; j&lt;tbodies.length; j++) {
					var rows = tbodies[j].getElementsByTagName(&quot;tr&quot;);
					for (var i=0; i&lt;rows.length; i++) {
						rows[i].oldClassName = rows[i].className;
						rows[i].onclick = function() {
							if (this.className.indexOf(&quot;selected&quot;) != -1) {
								this.className = this.oldClassName;
							} else {
								addClass(this,&quot;selected&quot;);
							}
							selectRowCheckbox(this);
						}
					}
				}
		}
	}
}
addLoadEvent(stripeTables);
addLoadEvent(highlightRows);
addLoadEvent(lockRow);
function lockRowUsingCheckbox() {
	var tables = document.getElementsByTagName(&quot;table&quot;);
	for (var m=0; m&lt;tables.length; m++) {
		if (tables[m].className == &quot;pickme&quot;) {
			var tbodies = tables[m].getElementsByTagName(&quot;tbody&quot;);
			for (var j=0; j&lt;tbodies.length; j++) {
				var checkboxes = tbodies[j].getElementsByTagName(&quot;input&quot;);
				for (var i=0; i&lt;checkboxes.length; i++) {
					checkboxes[i].onclick = function(evt) {
						if (this.parentNode.parentNode.className.indexOf(&quot;selected&quot;) != -1){
							this.parentNode.parentNode.className = this.parentNode.parentNode.oldClassName;
						} else {
							addClass(this.parentNode.parentNode,&quot;selected&quot;);
						}
						if (window.event &amp;&amp; !window.event.cancelBubble) {
							window.event.cancelBubble = &quot;true&quot;;
						} else {
							evt.stopPropagation();
						}
					}
				}
			}
		}
	}
}
addLoadEvent(lockRowUsingCheckbox);
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Table 2&lt;/h1&gt;
&lt;table
	id=&quot;striped2&quot;
	class=&quot;pickme&quot;
	caption=&quot;Top Grossing Movies&quot;&gt;
&lt;thead&gt;
&lt;tr&gt;
	&lt;th&gt; &lt;/th&gt;
	&lt;th&gt;Category&lt;/th&gt;
	&lt;th&gt;Movie&lt;/th&gt;
	&lt;th&gt;Gross&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
	&lt;td&gt;
		&lt;input
			type=&quot;checkbox&quot;
			name=&quot;tablechoice1&quot;
			value=&quot;walalala&quot; /&gt;
	&lt;/td&gt;
 	&lt;td&gt;Domestic&lt;/td&gt;
	&lt;td&gt;Titanic&lt;/td&gt;
	&lt;td&gt;$600,788,188&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;
		&lt;input
			type=&quot;checkbox&quot;
			name=&quot;tablechoice2&quot;
			value=&quot;walalala&quot; /&gt;
	&lt;/td&gt;
	&lt;td&gt;Adjusted for Inflation&lt;/td&gt;
	&lt;td&gt;Gone with the Wind&lt;/td&gt;
	&lt;td&gt;$1,329,453,600&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;
		&lt;input
			type=&quot;checkbox&quot;
			name=&quot;tablechoice3&quot;
			value=&quot;walalala&quot; /&gt;
	&lt;/td&gt;
	&lt;td&gt;Worldwide&lt;/td&gt;
	&lt;td&gt;Titanic&lt;/td&gt;
	&lt;td&gt;$1,845,034,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;
		&lt;input
			type=&quot;checkbox&quot;
			name=&quot;tablechoice4&quot;
			value=&quot;walalala&quot; /&gt;
	&lt;/td&gt;
	&lt;td&gt;R-Rating&lt;/td&gt;
	&lt;td&gt;The Passion of the Christ&lt;/td&gt;
	&lt;td&gt;$370,274,604&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;
		&lt;input
			type=&quot;checkbox&quot;
			name=&quot;tablechoice5&quot;
			value=&quot;walalala&quot; /&gt;
	&lt;/td&gt;
	&lt;td&gt;PG-13 Rating&lt;/td&gt;
	&lt;td&gt;Titanic&lt;/td&gt;
	&lt;td&gt;$600,788,188&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;
		&lt;input
			type=&quot;checkbox&quot;
			name=&quot;tablechoice6&quot;
			value=&quot;walalala&quot; /&gt;
	&lt;/td&gt;
	&lt;td&gt;PG-Rating&lt;/td&gt;
	&lt;td&gt;Star Wars&lt;/td&gt;
	&lt;td&gt;$460,998,007&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;
		&lt;input
			type=&quot;checkbox&quot;
			name=&quot;tablechoice7&quot;
			value=&quot;walalala&quot; /&gt;
	&lt;/td&gt;
	&lt;td&gt;G-Rating&lt;/td&gt;
	&lt;td&gt;Finding Nemo&lt;/td&gt;
	&lt;td&gt;$339,714,978&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;
		&lt;input
			type=&quot;checkbox&quot;
			name=&quot;tablechoice8&quot;
			value=&quot;walalala&quot; /&gt;
	&lt;/td&gt;
	&lt;td&gt;NC-17 Rating&lt;/td&gt;
	&lt;td&gt;Showgirls&lt;/td&gt;
	&lt;td&gt;$20,350,754&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;
		&lt;input
			type=&quot;checkbox&quot;
			name=&quot;tablechoice9&quot;
			value=&quot;walalala&quot; /&gt;
	&lt;/td&gt;
	&lt;td&gt;Movies that never hit #1&lt;/td&gt;
	&lt;td&gt;My Big Fat Greek Wedding&lt;/td&gt;
	&lt;td&gt;241,438,208&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td&gt;
		&lt;input
			type=&quot;checkbox&quot;
			name=&quot;tablechoice10&quot;
			value=&quot;walalala&quot; /&gt;
	&lt;/td&gt;
	&lt;td&gt;IMAX&lt;/td&gt;
	&lt;td&gt;Everest&lt;/td&gt;
	&lt;td&gt;$87,178,599&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_ANvRgY');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_ANvRgY');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_ANvRgY','runcode_ANvRgY');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>9、对联与旗帜:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_Uzlk2f">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;符合标准的正常工作的对联广告(www.hemin.cn)&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
&lt;!--
lastScrollY = 0;
function heartBeat(){
var diffY;
if (document.documentElement &amp;&amp; document.documentElement.scrollTop)
 diffY = document.documentElement.scrollTop;
else if (document.body)
 diffY = document.body.scrollTop
else
    {/*Netscape stuff*/}
//alert(diffY);
percent=.1*(diffY-lastScrollY);
if(percent&gt;0)percent=Math.ceil(percent);
else percent=Math.floor(percent);
document.getElementById(&quot;leftDiv&quot;).style.top = parseInt(document.getElementById(&quot;leftDiv&quot;).style.top)+percent+&quot;px&quot;;
document.getElementById(&quot;rightDiv&quot;).style.top = parseInt(document.getElementById(&quot;leftDiv&quot;).style.top)+percent+&quot;px&quot;;
lastScrollY=lastScrollY+percent;
//alert(lastScrollY);
}
//下面这段删除后，对联将不跟随屏幕而移动。
window.setInterval(&quot;heartBeat()&quot;,1);
//--&gt;
&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
&lt;!--
/* 这里定义滴是页面高度，用来测试对联跟随效果滴，跟广告无关 */
html,body{height:1000px;}
#mm{height:1000px;}
/* 这里是设置对联样式滴 */
#leftDiv,#rightDiv{
   width:120px; /* 宽度 */
   height:250px; /* 高度 */
   background-color:#e5e5e5; /* 背景颜色 */
   border:1px solid #ddd; /* 边框样式 */
   position:absolute; /* 绝对定位激活 */
}
--&gt;
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;leftDiv&quot; style=&quot;top:120px; /* 距离顶部120px */ left:2px; /* 距离左侧2px */ &quot;&gt;左侧广告内容&lt;/div&gt;
&lt;div id=&quot;rightDiv&quot; style=&quot;top:120px; /* 距离顶部120px */ right:2px; /* 距离右侧2px */ &quot;&gt;右侧广告内容&lt;/div&gt;
&lt;div id=&quot;mm&quot;&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_Uzlk2f');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_Uzlk2f');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_Uzlk2f','runcode_Uzlk2f');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>10、密码强度提示 :</strong>(www.hemin.cn)</p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_tCDJuC">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;密码强度提示(www.hemin.cn)&lt;/title&gt;
&lt;head&gt;
&lt;style&gt;
body
{
	/*ie needs this*/
	margin:0px;
	padding:0px;
	/*set global font settings*/
	font-size:10px;
	font-family:Tahoma,Verdana,Arial;
}
a:hover
{
	color:#fff;
}
#user_registration
{
	border:1px solid #cccccc;
	margin:auto auto;
	margin-top:100px;
	width:400px;
}
#user_registration label
{
        display: block;  /* block float the labels to left column, set a width */
	float: left;
	width: 70px;
	margin: 0px 10px 0px 5px;
	text-align: right;
	line-height:1em;
	font-weight:bold;
}
#user_registration input
{
	width:250px;
}
#user_registration p
{
	clear:both;
}
#submit
{
	border:1px solid #cccccc;
	width:100px !important;
	margin:10px;
}
h1
{
	text-align:center;
}
#passwordStrength
{
	height:10px;
	display:block;
	float:left;
}
.strength0
{
	width:250px;
	background:#cccccc;
}
.strength1
{
	width:50px;
	background:#ff0000;
}
.strength2
{
	width:100px;
	background:#ff5f5f;
}
.strength3
{
	width:150px;
	background:#56e500;
}
.strength4
{
	background:#4dcd00;
	width:200px;
}
.strength5
{
	background:#399800;
	width:250px;
}
&lt;/style&gt;
&lt;/style&gt;
&lt;script&gt;
function passwordStrength(password)
{
	var desc = new Array();
	desc[0] = &quot;Very Weak&quot;;
	desc[1] = &quot;Weak&quot;;
	desc[2] = &quot;Better&quot;;
	desc[3] = &quot;Medium&quot;;
	desc[4] = &quot;Strong&quot;;
	desc[5] = &quot;Strongest&quot;;
	var score   = 0;
	//if password bigger than 6 give 1 point
	if (password.length &gt; 6) score++;
	//if password has both lower and uppercase characters give 1 point
	if ( ( password.match(/[a-z]/) ) &amp;&amp; ( password.match(/[A-Z]/) ) ) score++;
	//if password has at least one number give 1 point
	if (password.match(/\d+/)) score++;
	//if password has at least one special caracther give 1 point
	if ( password.match(/.[!,@,#,$,%,^,&amp;,*,?,_,~,-,(,)]/) )	score++;
	//if password bigger than 12 give another 1 point
	if (password.length &gt; 12) score++;
	 document.getElementById(&quot;passwordDescription&quot;).innerHTML = desc[score];
	 document.getElementById(&quot;passwordStrength&quot;).className = &quot;strength&quot; + score;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form method=&quot;post&quot; action=&quot;&quot; id=&quot;user_registration&quot; name=&quot;user_registration&quot;&gt;
		&lt;p&gt;&lt;h1&gt;Password strength metter&lt;/h1&gt;&lt;/p&gt;
		&lt;p&gt;
			&lt;label for=&quot;pass&quot;&gt;Password&lt;/label&gt;&lt;input type=&quot;password&quot; name=&quot;pass&quot; id=&quot;pass&quot; onkeyup=&quot;passwordStrength(this.value)&quot;/&gt;
		&lt;/p&gt;
		&lt;p&gt;
		&lt;label for=&quot;pass2&quot;&gt;Confirm Password&lt;/label&gt;&lt;input type=&quot;password&quot; name=&quot;pass2&quot; id=&quot;pass2&quot;/&gt;
		&lt;/p&gt;
		&lt;p&gt;
			&lt;label for=&quot;passwordStrength&quot;&gt;Password strength&lt;/label&gt;
			&lt;div id=&quot;passwordDescription&quot;&gt;Password not entered&lt;/div&gt;
			&lt;div id=&quot;passwordStrength&quot; class=&quot;strength0&quot;&gt;&lt;/div&gt;
		&lt;/p&gt;
		&lt;p&gt;
		&lt;input type=&quot;submit&quot; name=&quot;submit&quot; id=&quot;submit&quot; value=&quot;Register&quot;&gt;
		&lt;/p&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_tCDJuC');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_tCDJuC');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_tCDJuC','runcode_tCDJuC');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>11、单行新闻滚动效果:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_wTaWra">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;单行新闻滚动效果(www.hemin.cn)&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
#rollText{font:12px /20px verdana;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;rollAD&quot; style=&quot;height:20px; position:relative; overflow:hidden; border:1px solid #FF0000;&quot;&gt;
                &lt;div id=&quot;rollText&quot; style=&quot;font-size:12px; line-height:20px;&quot;&gt;
                    &lt;a href=&quot;&quot;&gt;1 安理会改革拟新增七理事国&lt;/a&gt;
                    &lt;a href=&quot;&quot;&gt;2 国务院领导工作分工确定&lt;/a&gt;
                    &lt;a href=&quot;&quot;&gt;3 安理会改革拟新增七理事国&lt;/a&gt;&lt;br /&gt;
                    &lt;a href=&quot;&quot;&gt;4 国务院领导工作分工确定&lt;/a&gt;
                    &lt;a href=&quot;&quot;&gt;5 安理会改革拟新增七理事国&lt;/a&gt;
                    &lt;a href=&quot;&quot;&gt;6 国务院领导工作分工确定&lt;/a&gt;&lt;br /&gt;
                    &lt;a href=&quot;&quot;&gt;7 国务院领导工作分工确定&lt;/a&gt;
                    &lt;a href=&quot;&quot;&gt;8 安理会改革拟新增七理事国&lt;/a&gt;
                    &lt;a href=&quot;&quot;&gt;9 国务院领导工作分工确定&lt;/a&gt;&lt;br /&gt;
                &lt;/div&gt;
            &lt;/div&gt;
                &lt;script type=&quot;text/javascript&quot;&gt;
// &lt;![CDATA[
var textDiv = document.getElementById(&quot;rollText&quot;);
var textList = textDiv.getElementsByTagName(&quot;a&quot;);
if(textList.length &gt; 2){
	var textDat = textDiv.innerHTML;
	var br = textDat.toLowerCase().indexOf(&quot;&lt;br&quot;,textDat.toLowerCase().indexOf(&quot;&lt;br&quot;)+3);
	//var textUp2 = textDat.substr(0,br);
	textDiv.innerHTML = textDat+textDat+textDat.substr(0,br);
	textDiv.style.cssText = &quot;position:absolute; top:0&quot;;
	var textDatH = textDiv.offsetHeight;MaxRoll();
}
var minTime,maxTime,divTop,newTop=0;
function MinRoll(){
	newTop++;
	if(newTop&lt;=divTop+20){
		textDiv.style.top = &quot;-&quot; + newTop + &quot;px&quot;;
	}else{
		clearInterval(minTime);
		maxTime = setTimeout(MaxRoll,5000);
	}
}
function MaxRoll(){
	divTop = Math.abs(parseInt(textDiv.style.top));
	if(divTop&gt;=0 &amp;&amp; divTop&lt;textDatH-40){
		minTime = setInterval(MinRoll,1);
	}else{
		textDiv.style.top = 0;divTop = 0;newTop=0;MaxRoll();
	}
}
// ]]&gt;
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_wTaWra');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_wTaWra');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_wTaWra','runcode_wTaWra');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>12、JS图片加载与获取远程图片大小:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_7uXBc1">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
  &lt;title&gt;JS图片加载与获取远程图片大小(www.hemin.cn)&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;input id=&quot;path&quot; value=&quot;http://www.google.cn/logos/meilanfang09.gif&quot; style=&quot;width:400px&quot; /&gt;&lt;button onclick=&quot;loadpic($('prev'),$('path').value)&quot;&gt;加载&lt;/button&gt;&lt;button onclick=&quot;getImgSize($('path').value);&quot;&gt;获取大小&lt;/button&gt;
&lt;div id=&quot;prev&quot;&gt;&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var $=function(id){
	return document.getElementById(id);
}
function loadpic(holder,url){
	holder.innerHTML='正在加载...';
	var img=new Image();
	img.src=url;
	var imgElem=document.createElement('img');
	var dick=setInterval(function(){
		if(img.complete){
			clearInterval(dick);
			holder.innerHTML='';
			imgElem.src=img.src;
			img=null;
			holder.appendChild(imgElem);
			return imgElem;
		}
	},50);
}
function getImgSize(url){
	var img=new Image();
	img.src=url;
	var imgElem=document.createElement('img');
	var dick=setInterval(function(){
		if(img.complete){
			clearInterval(dick);
			imgElem.src=img.src;
			img=null;
			document.body.appendChild(imgElem);
			imgElem.style.visibility='hidden';
			alert('图片宽度:'+imgElem.offsetWidth+'\r\n图片高度:'+imgElem.offsetHeight);
			document.body.removeChild(imgElem);
		}
	},50);
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_7uXBc1');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_7uXBc1');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_7uXBc1','runcode_7uXBc1');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>13、JavaScript碰撞效果:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_3SaahC">
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;TITLE&gt;JavaScript碰撞效果(www.hemin.cn)&lt;/TITLE&gt;
&lt;FCK:META http-equiv=Content-Type content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;FCK:META content=&quot;Gerard Ferrandez at &lt;a target=&quot;_blank&quot; href=&quot;http://www.dhteumeuleu.com&quot; rel=&quot;external&quot;&gt;http://www.dhteumeuleu.com&lt;/a&gt;&quot; name=author /&gt;
&lt;FCK:META http-equiv=imagetoolbar content=no /&gt;
&lt;STYLE type=text/css&gt;
BODY {
	PADDING-RIGHT: 0px;
	PADDING-LEFT: 0px;
	BACKGROUND: #000000;
	LEFT: 0px;
	PADDING-BOTTOM: 0px;
	MARGIN: 0px;
	OVERFLOW: hidden;
	WIDTH: 100%;
	CURSOR: url('http://www.dhteumeuleu.com/no.cur');
	PADDING-TOP: 0px;
	POSITION: absolute;
	TOP: 0px;
	HEIGHT: 100%
}
SPAN {
	POSITION: absolute
}
&lt;/STYLE&gt;
&lt;SCRIPT type=text/javascript&gt;&lt;!--
// ====================================================
// script: Gerard Ferrandez - Ge-1-doot - DECEMBER 2K4
// &lt;a target=&quot;_blank&quot; href=&quot;http://www.dhteumeuleu.com/&quot; rel=&quot;external&quot;&gt;http://www.dhteumeuleu.com/&lt;/a&gt;
// crossbrowser: IE6 - Firefox - Opera - NS7
// ====================================================
window.onerror = new Function(&quot;return true&quot;)
var O   = new Array()
var SH  = SW = SPA = SO = xm = ym = XQ = YQ = YB = XB = 0
var pS  = 25
var pQ  = 100
var pQ2 = pQ / 2
var pS2 = pS / 2
function CObj(N){
	this.N = N
	o = document.createElement(&quot;span&quot;)
	SPA.appendChild(o)
	with(o.style){
		top = -pS
		width = pS
		height = pS
		fontSize = &quot;1px&quot;
		background = &quot;#000000&quot;
		border = &quot;gray solid 1px&quot;
	}
	this.pO = o.style
	this.pX = 0
	this.pY = 1000
	this.zX = 0
	this.zY = 1
	this.Li = false
	this.run = function () {
		with (this) {
			zX *= .95
			pY += zY
			pX += zX
			zY += .1 + N * .001
			if(pY&gt;SH){
				pY = -pS
				pX = Math.round(Math.random() * SW)
				zY = 0
				zX = 0
				pO.background = &quot;#000000&quot;
			}
			if(pX &gt;= XQ - pS2 &amp;&amp; pX &lt;= XQ + pQ + pS2 &amp;&amp; pY &gt;= YQ - pS &amp;&amp; pY &lt;= YQ + pQ){
				pY -= zY
				zX += ((pX &gt;= XQ + pQ2)?1:-1) * (.5 * zY + Math.abs(YQ - YB) * .2)
				if(pY &lt; YQ - (YQ - YB)) pY = YQ - pS, zY = 0; else pX += XQ - XB;
				if(!Li){
					Li = true
					pO.background = &quot;#FFFFFF&quot;
					setTimeout(&quot;O[&quot;+N+&quot;].Li=false;O[&quot;+N+&quot;].pO.background='#000000'&quot;, 1200)
				}
			}
			pO.left = pX - pS2
			pO.top  = pY
			setTimeout(&quot;O[&quot;+N+&quot;].run()&quot;, 16)
		}
	}
}
function pQM(){
	YB = YQ
	XB = XQ
	XQ = SO.left = xm - pQ2
	YQ = SO.top  = ym - pQ2
	setTimeout(pQM, 16)
}
function resize() {
	with(SPA.style){
		L = left = Math.round(-1+(document.body.offsetWidth - SW) / 2)
		H = top  = Math.round(-1+(document.body.offsetHeight - SH) / 2)
		width    = SW
		height   = SH
	}
}
onresize = resize
onload = function (){
	document.onmousemove = function(e){
		if (window.event) e = window.event
		xm = (e.x || e.clientX) - L
		ym = (e.y || e.clientY) - H
	}
	SPA = document.getElementById(&quot;SPAN&quot;)
	SO  = document.getElementById(&quot;SPLASH&quot;).style
	SO.width  = pQ
	SO.height = pQ
	SH  = document.body.offsetHeight
	SW  = pQ - pS2
	SX  = Math.round(SW / pS) - 1
	xm  = SW / 2
	ym  = SH / 2
	resize()
	pQM()
	for(j=0;j&lt;60;j++){
		O[j] = new CObj(j)
		setTimeout(&quot;O[&quot;+j+&quot;].run()&quot;,j * 123)
	}
}
//--&gt;
&lt;/SCRIPT&gt;
&lt;FCK:META content=&quot;MSHTML 6.00.3790.4210&quot; name=GENERATOR /&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;DIV id=SPAN style=&quot;BACKGROUND: #222222; POSITION: absolute&quot;&gt;
  &lt;DIV id=SPLASH
style=&quot;BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; FONT-SIZE: 1px; BACKGROUND: #000000; BORDER-LEFT: gray 1px solid; BORDER-BOTTOM: gray 1px solid; POSITION: absolute; TOP: -1000px&quot;&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/body&gt;
&lt;/HTML&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_3SaahC');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_3SaahC');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_3SaahC','runcode_3SaahC');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>14、来回移动:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_NHxFEn">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;来回移动(www.hemin.cn)&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
body{margin:0 auto;padding:0;width:80%;height:200px;position:relative;border:solid 1px #aaa;}
	#a,#b,#c,#d,#e{position:absolute;height:20}
	#a{width:50px;background:green;top:40px;}
	#b{width:20px;background:#aaa;top:70px;}
	#c{width:20px;background:red;top:100px;}
	#d{width:120px;background:blue;top:130px;}
	#e{width:20px;background:#000;top:170px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;容器来回移动&lt;/h1&gt;
	&lt;div id=&quot;a&quot;&gt; &amp;nbsp; &lt;/div&gt;
	&lt;div id=&quot;b&quot;&gt; &amp;nbsp; &lt;/div&gt;
	&lt;div id=&quot;c&quot;&gt; &amp;nbsp; &lt;/div&gt;
	&lt;div id=&quot;d&quot;&gt; &amp;nbsp; &lt;/div&gt;
	&lt;div id=&quot;e&quot;&gt; &amp;nbsp; &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function moveBlock(obj,speed){
	if(!obj.style.left){obj.style.left=&quot;0&quot;;}
	//获取#block的宽度
	var blockW=parseInt(obj.offsetWidth,10);
	var blockLeft=parseInt(obj.style.left,10);
	var bodyW=parseInt(document.body.offsetWidth);
	//如果块在最左边，那么向右方运动
	if(blockLeft==0){
		obj.setAttribute(&quot;path&quot;,&quot;true&quot;);
	}
	//如果块已经溢出右边界，那么向左运动
	if(blockLeft+blockW&gt;=bodyW){
		obj.setAttribute(&quot;path&quot;,&quot;false&quot;);
	}
	//根据path这个自定义属性，来判断是该向左还是向右运动
	if(obj.getAttribute(&quot;path&quot;)==&quot;true&quot;){
		blockLeft+=speed;
		if(blockLeft+blockW&gt;bodyW){
			obj.style.left=bodyW-blockW+&quot;px&quot;;
		}else{
			obj.style.left=blockLeft+&quot;px&quot;;
		}
	}else{
		blockLeft-=speed;
		if(blockLeft&lt;0){blockLeft=0;}
		obj.style.left=blockLeft+&quot;px&quot;;
	}
}
function run(obj,speed,delay){window.setInterval(function(){moveBlock(obj,speed);},delay)}
var a=document.getElementById(&quot;a&quot;);
var b=document.getElementById(&quot;b&quot;);
var c=document.getElementById(&quot;c&quot;);
var d=document.getElementById(&quot;d&quot;);
var e=document.getElementById(&quot;e&quot;);
/*
	run(容器对象,步长(px),延迟)
*/
run(a,5,10);
run(b,1,10);
run(c,10,10);
run(d,20,10);
run(e,15,50);
&lt;/script&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_NHxFEn');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_NHxFEn');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_NHxFEn','runcode_NHxFEn');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>15、Javascript 控制 CheckBox 的全选与取消全选:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_CMM59E">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
 &lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
  &lt;title&gt;Javascript 控制 CheckBox 的全选与取消全选(www.hemin.cn) &lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function checkAll(name)
{
	var el = document.getElementsByTagName('input');
	var len = el.length;
	for(var i=0; i&lt;len; i++)
	{
		if((el[i].type==&quot;checkbox&quot;) &amp;&amp; (el[i].name==name))
		{
			el[i].checked = true;
		}
	}
}
function clearAll(name)
{
	var el = document.getElementsByTagName('input');
	var len = el.length;
	for(var i=0; i&lt;len; i++)
	{
		if((el[i].type==&quot;checkbox&quot;) &amp;&amp; (el[i].name==name))
		{
			el[i].checked = false;
		}
	}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;input type=&quot;checkbox&quot; name=&quot;test&quot; value=&quot;&quot; onclick=&quot;if(this.checked==true) { checkAll('test'); } else { clearAll('test'); }&quot; /&gt; 字母全选开关
&lt;input type=&quot;checkbox&quot; name=&quot;test&quot; value=&quot;a&quot; /&gt; a
&lt;input type=&quot;checkbox&quot; name=&quot;test&quot; value=&quot;b&quot; /&gt; b
&lt;input type=&quot;checkbox&quot; name=&quot;test&quot; value=&quot;c&quot; /&gt; c
&lt;input type=&quot;checkbox&quot; name=&quot;test&quot; value=&quot;d&quot; /&gt; d
&lt;input type=&quot;checkbox&quot; name=&quot;test&quot; value=&quot;e&quot; /&gt; e
&lt;input type=&quot;checkbox&quot; name=&quot;test&quot; value=&quot;f&quot; /&gt; f
&lt;input type=&quot;checkbox&quot; name=&quot;test&quot; value=&quot;g&quot; /&gt; g
&lt;br /&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;num&quot; value=&quot;&quot; onclick=&quot;if(this.checked==true) { checkAll('num'); } else { clearAll('num'); }&quot;  /&gt; 数字全选开关
&lt;input type=&quot;checkbox&quot; name=&quot;num&quot; value=&quot;1&quot; /&gt; 1
&lt;input type=&quot;checkbox&quot; name=&quot;num&quot; value=&quot;2&quot; /&gt; 2
&lt;input type=&quot;checkbox&quot; name=&quot;num&quot; value=&quot;3&quot; /&gt; 3
&lt;br /&gt;&lt;br /&gt;
&lt;input type=&quot;button&quot; value=&quot;选择所有的字母&quot; onclick=&quot;checkAll('test')&quot; /&gt;
&lt;input type=&quot;button&quot; value=&quot;清空选中的字母&quot; onclick=&quot;clearAll('test')&quot; /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;input type=&quot;button&quot; value=&quot;选择所有的数字&quot; onclick=&quot;checkAll('num')&quot; /&gt;
&lt;input type=&quot;button&quot; value=&quot;清空选中的数字&quot; onclick=&quot;clearAll('num')&quot; /&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_CMM59E');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_CMM59E');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_CMM59E','runcode_CMM59E');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>16、javascript彩色喷泉:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_DkN388">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt; Fountain &lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;style type=&quot;text/css&quot;&gt;
#stage {width:200px; height:400px; border:1px solid #993300; position:relative; margin:auto;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;stage&quot;&gt;
	&lt;div id=&quot;fountain&quot;&gt;&lt;/div&gt;
	&lt;input type=&quot;button&quot; value=&quot;Run&quot; id=&quot;run&quot; /&gt;
	&lt;input type=&quot;button&quot; value=&quot;Stop&quot; id=&quot;stop&quot; /&gt;
&lt;/div&gt;
&lt;script&gt;
/**
 * 小球类 Ball
 * @param {number} diameter 直径
 */
 var Ball = function(diameter, x, y, vx, vy) {
	var ball = document.createElement('div');
	var r = Math.floor(Math.random() * 255);
	var g = Math.floor(Math.random() * 255);
	var b = Math.floor(Math.random() * 255);
	ball.style.width = ball.style.height = diameter + 'px';
	ball.style.backgroundColor = 'rgb('+r+', '+g+', '+b+')';
	ball.style.left = x + 'px'; ball.style.top = y + 'px'; ball.vx = vx; ball.vy = vy; ball.style.position = 'absolute';
	return ball;
 };
 function T$(id) { return document.getElementById(id) }
/**
 * 喷泉主类 Fountain
 * @param {string} 舞台ID
 * @param {number} 水滴数目
 * @param {number} 重力加速度
 */
 var Fountain = function(stage, count, gravity) {
	this.stage = T$(stage);
	this.count = count;
	this.gravity = gravity;
	this.timer = null;
 };
 Fountain.prototype = {
	constructor: Fountain,
	initialize: function() {
		// 生成一定数目的随机颜色小球
		var self = this, count = self.count, j = 0,
			frag = document.createDocumentFragment(),
			stage = self.stage, gravity = self.gravity;
		// 设置小球参数(直径, 半径,  舞台位置)
		var diameter = 4, radius = diameter / 2, x = stage.clientWidth / 2, y = stage.clientHeight;
		var balls = new Array();
		for (; j &lt; count; j++) {
			var ball = new Ball(diameter, x, y, Math.random() * 4 - 1, Math.random() * -10 - 10);
			balls[j] = ball;
			frag.appendChild(ball);
		}
		T$('fountain').innerHTML = '';
		T$('fountain').appendChild(frag);
		clearTimeout(self.timer);
		function Run() {
			for (var i = 0, len = balls.length; i &lt; len; i++) {
				var ball = balls[i];
				ball.vy += gravity;
				ball.style.left = (ball.offsetLeft + ball.vx) + 'px';
				ball.style.top = (ball.offsetTop + ball.vy) + 'px';
				// 边界检测
				if (ball.offsetLeft - radius &gt; x || ball.offsetLeft + radius &lt; 0
					|| ball.offsetTop - radius &gt; y || ball.offsetTop + radius &lt; 0)
				{
					ball.style.left = x + 'px';
					ball.style.top = y + 'px';
					ball.vx = Math.random() * 4 - 1;
					ball.vy = Math.random() * -10 - 10;
				}
			}
			self.timer = setTimeout(Run, 10);
		}
		Run();
	}
 };
 // 在舞台中央生成30个彩色水滴. 重力加速度为.5
 var fountain = new Fountain('stage', 30, 0.5);
 T$('run').onclick = function() {
	fountain.initialize();
 }
 T$('stop').onclick = function() {
	clearTimeout(fountain.timer);
 }
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_DkN388');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_DkN388');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_DkN388','runcode_DkN388');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>17、javascript行星运动:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_zNY02w">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt; 银河星系 &lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;style type=&quot;text/css&quot;&gt;
#content { width:600px; height:200px; position:relative; left:0px; top:0px; }
#graph {position:absolute; left:0; top:0}
#sun {position:absolute; width:20px; height:20px; line-height:20px; left: 290px; top:90px; background-color:blue}
#planet{position:absolute; width:5px; height:5px; left: -100px; top:-100px; background-color:red}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;content&quot;&gt;
	&lt;div id=&quot;graph&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;sun&quot;&gt;&lt;/div&gt;
	&lt;div id=&quot;planet&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;input type=&quot;button&quot; value=&quot;Run&quot; id=&quot;run&quot; /&gt;
&lt;input type=&quot;button&quot; value=&quot;Stop&quot; id=&quot;stop&quot; /&gt;
&lt;script&gt;
function T$(i) { return document.getElementById(i); }
var math = function() {
	var planet = T$('planet');
		xlen = T$('content').clientWidth,
		ylen = T$('content').clientHeight,
		x_posy = ylen / 2,
		y_posx = xlen / 2,
		angle = 0;
	var galaxy = function() {
		var self = this;
		if (!(self instanceof galaxy)) {
			return new galaxy();
		}
		self.timer = null;
		self.initialize();
	}
	galaxy.prototype = {
		initialize: function() {
			var self = this;
			self.drawXaxis();
			self.drawYaxis();
			self.drawGalaxy();
		},
		drawXaxis: function() {
			var self = this;
			for (var i = 0, arr = []; i &lt; xlen; ++i) {
				arr[i] = self.createDot(1, 1, i, x_posy, '#213478');
			}
			T$('graph').innerHTML += arr.join('');
		},
		drawYaxis: function() {
			var self = this, amp = self.amp;
			for (var i = 0, arr = []; i &lt; ylen; ++i) {
				arr[i] = self.createDot(1, 1, y_posx, i, '#213478');
			}
			T$('graph').innerHTML += arr.join('');
		},
		drawGalaxy: function() {
			var self = this;
			for (var i = 0, arr = []; i &lt; xlen; ++i) {
				arr[i] = self.createDot(1, 1, y_posx + Math.sin(angle+=.01) * y_posx , x_posy + Math.cos(angle+=.01) * x_posy, '#213478');
			}
			T$('graph').innerHTML += arr.join('');
		},
		runPlanet: function() {
			var self = this;
			self.timer = setInterval(function() {
				planet.style.left = (y_posx + Math.sin(angle+=.01) * y_posx) + 'px';
				planet.style.top = (x_posy + Math.cos(angle+=.01) * x_posy) + 'px';
			}, 40);
		},
		createDot: function(w, h, x, y, c) {
			return '&lt;div style=&quot;width:'+w+'px;height:'+h+'px;font-size:0;background-color:'+c+';position:absolute;left:'+x+'px;top:'+y+'px;&quot;&gt;&lt;\/div&gt;';
		}
	}
	return {galaxy : galaxy}
}();
var galaxy = math.galaxy();
T$('run').onclick = function() {
	clearInterval(galaxy.timer);
	galaxy.runPlanet();
}
T$('stop').onclick = function() {
	clearInterval(galaxy.timer);
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_zNY02w');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_zNY02w');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_zNY02w','runcode_zNY02w');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>18、javascript正弦曲线:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_WWVbKl">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt; 正弦曲线 &lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;style type=&quot;text/css&quot;&gt;
#content { width:600px; height:200px; border:1px solid #213478; position:relative; left:0px; top:0px; }
#graph {position:absolute; left:0; top:0}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;content&quot;&gt;
	&lt;div id=&quot;graph&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;script&gt;
var math = function() {
	function T$(i) { return document.getElementById(i); }
	var xlen = T$('content').clientWidth; x_posy = T$('content').clientHeight / 2, angle = 0;
	function drawSine(amp) {
		var self = this;
		if (!(self instanceof drawSine)) {
			return new drawSine(amp);
		}
		self.amp = amp;
		self.initialize();
	}
	drawSine.prototype = {
		initialize: function() {
			var self = this;
			self.drawXaxis();
			self.drawYaxis();
		},
		drawXaxis: function() {
			var self = this;
			for (var i = 0, arr = []; i &lt; xlen; ++i) {
				arr[i] = self.createDot(1, 1, i, x_posy, '#213478');
			}
			T$('graph').innerHTML += arr.join('');
		},
		drawYaxis: function() {
			var self = this, amp = self.amp;
			for (var i = 0, arr = []; i &lt; xlen; ++i) {
				arr[i] = self.createDot(2, 2, i += amp, x_posy + Math.sin(angle+=.1) * x_posy, '#FF9933');
			}
			T$('graph').innerHTML += arr.join('');
		},
		createDot: function(w, h, x, y, c) {
			return '&lt;div style=&quot;width:'+w+'px;height:'+h+'px;font-size:0;background-color:'+c+';position:absolute;left:'+x+'px;top:'+y+'px;&quot;&gt;&lt;\/div&gt;';
		}
	}
	return {drawSine: drawSine}
}();
math.drawSine(2 /* 波长 */);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_WWVbKl');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_WWVbKl');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_WWVbKl','runcode_WWVbKl');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>19、javascript手风琴菜单:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_aiilhG">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;accordion&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
* {margin:0; padding:0}
#accordion {width:259px; margin:50px auto; border:1px solid #333; border-top:none}
.accordion {width:259px; font:12px Verdana, Arial; color:#333}
.accordion dt {width:247px; padding:4px 6px; font-weight:bold; cursor:pointer; background-color:#666; background-image:url(images/arrow_down.gif); background-position: right center; background-repeat:no-repeat; color:#fff; border-top: 1px solid #333}
.accordion dt:hover {background-color:#555}
.accordion .open {background-color:#444; background-image:url(images/arrow_up.gif)}
.accordion dd {overflow:hidden; background:#fff;}
.accordion span {display:block; width:229px; border-top:none; padding:15px}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var accordion = function() {
	var tm = sp = 10;
	function slider(t, c, k) {
		var self = this;
		if (!(self instanceof slider)) {
			return new slider(t, c, k);
		}
		self.nm = t;
		self.arr = [];
		self.init(t, c, k);
	}
	slider.prototype.pro = function(d) {
		for (var i = 0; i &lt; this.l; i++) {
			var h = this.arr[i], s = h.nextSibling; s = s.nodeType != 1 ? s.nextSibling : s;
			clearInterval(s.tm);
			if (h == d &amp;&amp; s.style.display == 'none') {
				s.style.display = '';
				su(s, 1);
				h.className = this.sl
			} else if (s.style.display == '') {
				su(s, -1);
				h.className = '';
			}
		}
	}
	slider.prototype.init = function(t, c, k) {
		var a, h, s, l, i, self = this; a = T$(t); self.sl = k ? k : '';
		h = T$$('dt', a); s = T$$('dd', a); self.l = h.length;
		for (i = 0; i &lt; self.l; i++) {
			var d = h[i]; self.arr[i] = d;
			d.onclick = function() { self.pro(this); }
			if (c == i) { d.className = self.sl; }
		}
		l = s.length;
		for (i = 0; i &lt; l; i++) {
			var d = s[i]; d.mh = d.offsetHeight;
			if (c != i) {
				d.style.height = 0;
				d.style.display = 'none';
			}
		}
	}
	function T$(o) { return document.getElementById(o); }
	function T$$(t, o) { return (o || document).getElementsByTagName(t); }
	function su(c, f) { c.tm = setInterval(function() { sl(c, f)}, tm); }
	function sl(c, f) {
		var h = c.offsetHeight, m = c.mh, d = f == 1 ? m - h : h;
		c.style.height = h + (Math.ceil(d / sp) * f) +  'px';
		c.style.opacity = h / m; c.style.filter = 'alpha(opacity=' + h * 100 / m + ')';
		if (f == 1 &amp;&amp; h &gt;= m) { clearInterval(c.tm)}
		else if (f != 1 &amp;&amp; h == 1) {
			c.style.display = 'none';
			clearInterval(c.tm);
		}
	}
	return {slider: slider}
}();
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;accordion&quot;&gt;
	&lt;dl class=&quot;accordion&quot; id=&quot;slider&quot;&gt;
		&lt;dt&gt;火影忍者&lt;/dt&gt;
		&lt;dd&gt;
			&lt;span&gt;
				从小身上封印着邪恶的九尾妖狐，无父无母的鸣人受尽了村里人的冷落，但是他却不知道原因，只是拼命用各种恶作剧试图吸引大家的注意力，
				人们却反而更远离他。好在还有依鲁卡老师关心他，
				&lt;img src=&quot;http://hiphotos.baidu.com/jonny1008/pic/item/16c65216d09434224a90a712.jpg&quot; width=&quot;100&quot; height=&quot;102&quot; alt=&quot;佩恩六道&quot; /&gt;
				&lt;img src=&quot;http://hiphotos.baidu.com/w2008wjay/pic/item/f4c1ad7a80acfbd72f73b349.jpg&quot; width=&quot;100&quot; height=&quot;100&quot; alt=&quot;漩涡鸣人&quot; /&gt;
				&lt;br /&gt;
				鸣人的性格才没有变得扭曲。他总是干劲十足，嘻嘻哈哈，超级乐观。为了让更多的人认可自己，
				鸣人的目标是——成为第六代火影！
			&lt;/span&gt;
		&lt;/dd&gt;
		&lt;dt&gt;天空之城&lt;/dt&gt;
		&lt;dd&gt;
			&lt;span&gt;
				故事发生的时间大概是十九世纪初，是个带有欧洲工业革命时期味道的年代，女孩希达被政府军软禁在飞艇上，灵敏的海盗们嗅到了希达身上不同一般人的身份，在深夜向飞艇发动了进攻，就在两方人马争夺西大的时候，慌乱逃跑的女孩不小心从飞艇上调了下去，可就在向着地面追落得时候，希达胸前的石头发出了耀眼的光芒，温柔的包围住希达，并慢慢落下地面，就在这时，矿工机师的徒弟巴斯在回程的路上看到了光芒中心的希达，并接下了她......&lt;br /&gt;
				&lt;img src=&quot;http://hiphotos.baidu.com/xlycy1/pic/item/293347d1c1ad4208960a167a.jpg&quot; width=&quot;220&quot; height=&quot;100&quot; alt=&quot;天空之城&quot; /&gt;
			&lt;/span&gt;
		&lt;/dd&gt;
		&lt;dt&gt;海贼王&lt;/dt&gt;
		&lt;dd&gt;
			&lt;span&gt;
				在某个海岛小渔村长大。和暂驻在渔村的大海盗红发杰克感情很好，于是一心想成为海盗。眼下的疤痕就是为了显示自己够狠自己用刀划的。可是路飞7岁时因为和杰克斗气糊里糊涂的吃了海盗们抢来的恶魔果实——橡皮果实（ゴムゴムの実），从此再也学不会游泳。&lt;br /&gt;
				&lt;img src=&quot;http://hiphotos.baidu.com/haigevsjunjie/pic/item/e6525c44bd65900ecefca3e9.jpg&quot; width=&quot;220&quot; height=&quot;100&quot; alt=&quot;海贼王&quot; /&gt;
			&lt;/span&gt;
		&lt;/dd&gt;
		&lt;dt&gt;死神&lt;/dt&gt;
		&lt;dd&gt;
			&lt;span&gt;
				主角是名叫黑崎一护的15岁高中生，是个热血少年。因一次被一种叫&quot;虚&quot;的怪物攻击时，认识了一个自称是死神的少女&quot;露琪亚&quot;。一护因为露琪亚给予了他力量而变成了死神，从此开始履行作为一个死神的职责--消灭虚...
				露琪亚将死神的力量传给人类这件事被尸魂界得知，于是朽木白哉和阿散井恋次被派到现世执行将露琪亚带回尸魂界并关押的任务（人物应该不用介绍吧~！）。露琪亚不想让一护卷进此事，于是孤身一人前去迎战，可是能力终究敌不上队长级的。就在危急关头，一护找到了露琪亚，并想阻止他们将其带走。但现在的一护毕竟不强，被朽木白哉连砍两刀，倒在血泊中。露琪亚含泪离开...	&lt;br /&gt;
				&lt;img src=&quot;http://hiphotos.baidu.com/zxcc1121/pic/item/de773508284dae0ae824886c.jpg&quot; width=&quot;220&quot; height=&quot;100&quot; alt=&quot;死神&quot; /&gt;
			&lt;/span&gt;
		&lt;/dd&gt;
	&lt;/dl&gt;
&lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
accordion.slider(&quot;slider&quot;, 0, &quot;open&quot;);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_aiilhG');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_aiilhG');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_aiilhG','runcode_aiilhG');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>20、javascript仿QQ滑动菜单:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_4tbdWs">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt; Slider &lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
body, td, ul, li { margin:0; padding:0 }
table { border-collapse: collapse; border-spacing:0 }
#container { width:610px; height:205px; position:relative; overflow: hidden; margin:0 auto; }
#scroller { position:absolute; }
#page { position: absolute; float:right; left:520px; top:180px;}
#page li { float:left; cursor:pointer; list-style:none; width:15px; height:15px; line-height:15px; font-family:Arial; font-size:12px; margin:1px; text-align:center;background:url(&quot;http://pc.qq.com/pc/images/flashbutton.gif&quot;) no-repeat scroll -15px 0 transparent;}
#page li.on {background:url(&quot;http://pc.qq.com/pc/images/flashbutton.gif&quot;) no-repeat scroll 0 0 transparent;color:#FFFFFF;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;container&quot;&gt;
	&lt;table id=&quot;scroller&quot; &gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;img src=&quot;http://inncache.soso.com/pc/images/manage.jpg&quot; /&gt;&lt;/td&gt;
			&lt;td&gt;&lt;img src=&quot;http://inncache.soso.com/pc/images/py.jpg&quot; /&gt;&lt;/td&gt;
			&lt;td&gt;&lt;img src=&quot;http://inncache.soso.com/pc/images/player.jpg&quot; /&gt;&lt;/td&gt;
			&lt;td&gt;&lt;img src=&quot;http://inncache.soso.com/pc/images/xf.jpg&quot; /&gt;&lt;/td&gt;
			&lt;td&gt;&lt;img src=&quot;http://inncache.soso.com/pc/images/TT.jpg&quot; /&gt;&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;
	&lt;ul id=&quot;page&quot;&gt;&lt;/ul&gt;
&lt;/div&gt;
&lt;script&gt;
var QQ = function() {
	// 公用函数
	function T$(id) { return document.getElementById(id); }
	function T$$(root, tag) { return (root || document).getElementsByTagName(tag); }
	function $extend(des, src) { for(var p in src) { des[p] = src[p]; } return des; }
	function $each(arr, callback, thisp) {
		if (arr.forEach) {arr.forEach(callback, thisp);}
		else { for (var i = 0, len = arr.length; i &lt; len; i++) callback.call(thisp, arr[i], i, arr);}
	}
	function currentStyle(elem, style) {
		return elem.currentStyle || document.defaultView.getComputedStyle(elem, null);
	}
	// 缓动类
	var Tween = {
		Quart: {
			easeOut: function(t,b,c,d){
				return -c * ((t=t/d-1)*t*t*t - 1) + b;
			}
		},
		Back: {
			easeOut: function(t,b,c,d,s){
				if (s == undefined) s = 1.70158;
				return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
			}
		},
		Bounce: {
			easeOut: function(t,b,c,d){
				if ((t/=d) &lt; (1/2.75)) {
					return c*(7.5625*t*t) + b;
				} else if (t &lt; (2/2.75)) {
					return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
				} else if (t &lt; (2.5/2.75)) {
					return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
				} else {
					return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
				}
			}
		}
	}
	// 主类构造函数
	var scrollTrans = function(cid, sid, count, config) {
		var self = this;
		if (!(self instanceof scrollTrans)) {
			return new scrollTrans(cid, sid, count, config);
		}
		self.container = T$(cid);
		self.scroller = T$(sid);
		if (!(self.container || self.scroller)) {
			return;
		}
		self.config = $extend(defaultConfig, config || {});
		self.index = 0;
		self.timer = null;
		self.count = count;
		self.step = self.scroller.offsetWidth / count;
	};
	// 默认配置
	var defaultConfig = {
		trigger: 1, // 触发方式1:click other: mouseover
		auto: true, // 是否自动切换
		tween: Tween.Quart.easeOut, // 默认缓动类
		Time: 10, // 滑动延时
		duration: 50,	// 切换时间
		pause: 3000, // 停顿时间
		start: function() {}, // 切换开始执行函数
		end: function() {} // 切换结束执行函数
	};
	scrollTrans.prototype = {
		constructor: scrollTrans,
		transform: function(index) {
			var self = this;
			index == undefined &amp;&amp; (index = self.index);
			index &lt; 0 &amp;&amp; (index = self.count - 1) || index &gt;= self.count &amp;&amp; (index = 0);
			self.time = 0;
			self.target = -Math.abs(self.step) * (self.index = index);
			self.begin = parseInt(currentStyle(self.scroller)['left']);
			self.change = self.target - self.begin;
			self.duration = self.config.duration;
			self.start();
			self.run();
		},
		run: function() {
			var self = this;
			clearTimeout(self.timer);
			if (self.change &amp;&amp; self.time &lt; self.duration) {
				self.moveTo(Math.round(self.config.tween(self.time++, self.begin, self.change, self.duration)));
				self.timer = setTimeout(function() {self.run()}, self.config.Time);
			} else {
				self.moveTo(self.target);
				self.config.auto &amp;&amp; (self.timer = setTimeout(function() {self.next()}, self.config.pause));
			}
		},
		moveTo: function(i) {
			this.scroller.style.left = i + 'px';
		},
		next: function() {
			this.transform(++this.index);
		}
	};
	return {
		scroll: function(cid, sid, count, config) {
				window.onload = function() {
					var frag = document.createDocumentFragment(),
						nums = [];
					for (var i = 0; i &lt; count; i++) {
						var li = document.createElement('li');
						(nums[i] = frag.appendChild(document.createElement('li'))).innerHTML = i + 1;
					}
					T$('page').appendChild(frag);
					// 调用主类
					var st = scrollTrans(cid, sid, count, config);
					$each(nums, function(o, i) {
						o[st.config.trigger == 1 ? 'onclick' : 'onmouseover'] = function() { o.className = 'on'; st.transform(i); }
						o.onmouseout = function() { o.className = ''; st.transform();}
					});
					st.start = function() {
						$each(nums, function(o, i) {
							o.className = st.index == i ? 'on' : '';
						});
					};
					st.transform();
				}
		}
	}
}();
QQ.scroll('container' /*外部容器ID*/, 'scroller'/*滑动容器ID*/, 5/*切换图片数目*/, {trigger: 0} /*默认配置*/);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_4tbdWs');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_4tbdWs');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_4tbdWs','runcode_4tbdWs');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>21、javascript简易动画类:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_vuL6af">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;title&gt; new document &lt;/title&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;center&gt;
	&lt;input type=&quot;button&quot; name=&quot;fx&quot; value=&quot;宽度渐变&quot; id=&quot;wt-cg&quot;/&gt;
	&lt;input type=&quot;button&quot; name=&quot;fx&quot; value=&quot;高度渐变&quot; id=&quot;hi-cg&quot;/&gt;
	&lt;input type=&quot;button&quot; name=&quot;fx&quot; value=&quot;透明度渐变&quot; id=&quot;op-cg&quot;/&gt;
	&lt;input type=&quot;button&quot; name=&quot;fx&quot; value=&quot;边框渐变&quot; id=&quot;bd-cg&quot;/&gt;
	&lt;input type=&quot;button&quot; name=&quot;fx&quot; value=&quot;综合渐变&quot; id=&quot;zh-cg&quot;/&gt;
	&lt;div id=&quot;demo&quot; style=&quot;width:370px;height:100px;background-color:#00CC33;border:2px solid #990033; font-size:12px;&quot;&gt;&lt;/div&gt;
&lt;/center&gt;
&lt;script&gt;
function Animate(el, prop, opts) {
	this.el = el;
	this.prop = prop;
	this.from = opts.from;
	this.to = opts.to;
	this.time = opts.time;
	this.callback = opts.callback;
	this.animDiff = this.to - this.from;
}
Animate.prototype._setStyle = function(val) {
	switch(this.prop) {
		case 'opacity':
			this.el.style[this.prop] = val;
			this.el.style.filter = 'alpha(opacity=' + val * 100 + ')';
			break;
		default:
			this.el.style[this.prop] = val + 'px';
			break;
	}
}
Animate.prototype._animate = function() {
	var that = this;
	this.now = new Date();
	this.diff = this.now - this.startTime;
	if (this.diff &gt; this.time) {
		this._setStyle(this.to);
		if (this.callback) {
			this.callback.call(this);
		}
		clearInterval(this.timer);
		return;
	}
	this.percentage = (Math.floor((this.diff / this.time) * 100) / 100);
	this.val = (this.animDiff * this.percentage) + this.from;
	this._setStyle(this.val);
}
Animate.prototype.start = function() {
	var that = this;
	this.startTime = new Date();
	clearInterval(this.timer);
	this.timer = setInterval(function() {
		that._animate.call(that);
	}, 4);
}
Animate.canTransition = function() {
	var el = document.createElement('foo');
	el.style.cssText = '-webkit-transition: all .5s linear;';
	return !!el.style.webkitTransitionProperty;
}();
window.onload = function() {
	var T$ = function(id) { return document.getElementById(id); }
	var T$$ = function(n) { return document.getElementsByName(n); }
	var demo = T$('demo'); var btns = T$$('fx');
	function disableButton() {
		for (var i = 0, len = btns.length; i &lt; len; ++i) {
			btns[i].disabled = 'disabled';
		}
	}
	function resetButton() {
		for (var i = 0, len = btns.length; i &lt; len; ++i) {
			btns[i].disabled = '';
		}
	}
	// 宽度渐变
	function changeWidth() {
		var fx = 'width', from = demo.clientWidth, to = from - 270, time = 1000;
		var callback = function() {
			from =  demo.clientWidth; to = from + 270;
			new Animate(demo, fx, { from: from, to: to, time: time, callback: resetButton }).start();
		}
		new Animate(demo, fx, {
			from: from,
			to: to,
			time: time,
			callback: callback
		}).start();
	}
	// 高度渐变
	function changeHeight() {
		var fx = 'height', from = demo.clientHeight, to = from + 100, time = 1000;
		var callback = function() {
			from = demo.clientHeight; to = from - 100;
			new Animate(demo, fx, { from: from, to: to, time: time, callback: resetButton}).start();
		}
		new Animate(demo, fx, {
			from: from,
			to: to,
			time: time,
			callback: callback
		}).start();
	}
	// 透明度渐变
	function changeOpacity() {
		var fx = 'opacity', from = 1, to = 0, time = 1000;
		var callback = function() {
			from = 0; to = 1;
			new Animate(demo, fx, { from: from, to: to, time: time, callback: resetButton}).start();
		}
		new Animate(demo, fx, {
			from: from,
			to: to,
			time: time,
			callback: callback
		}).start();
	}
	// 边框渐变
	function changeBorderWidth() {
		var fx = 'borderWidth', from = 2, to = 10, time = 1000;
		var callback = function() {
			from = 10; to = 2;
			new Animate(demo, fx, { from: from, to: to, time: time, callback: resetButton }).start();
		}
		new Animate(demo, fx, {
			from: from,
			to: to,
			time: time,
			callback: callback
		}).start();
	}
	T$('wt-cg').onclick = function() {
		disableButton(); changeWidth();
	}
	T$('hi-cg').onclick = function() {
		disableButton(); changeHeight();
	}
	T$('op-cg').onclick = function() {
		disableButton(); changeOpacity();
	}
	T$('bd-cg').onclick = function() {
		disableButton(); changeBorderWidth();
	}
	T$('zh-cg').onclick = function() {
		disableButton(); changeWidth(); changeHeight(); changeOpacity();
	}
	//if (Animate.canTransition) {
		//demo.style.webkitTransition = 'opacity 3s ease-in';
		//demo.style.opacity = 0;
	//} else {
	//}
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_vuL6af');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_vuL6af');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_vuL6af','runcode_vuL6af');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>22、简单的原生态JavaScript缓动效果:</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_4eOkOy">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;简单的原生态JavaScript缓动效果&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
	#show{
		width:100px;
		height:100px;
		background:#eee;
		border:1px solid #800;
		opacity:0.8;
		filter:alpha(opacity=80);
	}
	#d1,#d2{
	    width:100px;
		height:100px;
		background:#fff;
		border:1px solid #333;
		position:absolute;
		left:1017px;
		top:100px;
		text-align:center;
		line-height:50px;
	}
	#d2{
	   left:100px;
	   top:525px;
	}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;d1&quot;&gt;第一个位置1017 100&lt;/div&gt;&lt;div id=&quot;d2&quot;&gt;第二个位置100 525&lt;/div&gt;
	&lt;div id=&quot;show&quot;&gt;&lt;/div&gt;
	&lt;button id=&quot;go&quot;&gt;第一个位置&lt;/button&gt;&lt;button id=&quot;stop&quot;&gt;第二个位置&lt;/button&gt;&lt;button id=&quot;pause&quot;&gt;暂停&lt;/button&gt;&lt;button id=&quot;goon&quot;&gt;继续&lt;/button&gt;
	&lt;div id=&quot;result&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var r=document.getElementById(&quot;result&quot;);
var store;
	var timer;
	function moveElement(elementID,final_x,final_y,interval){
		if(!document.getElementById) return false;
		if(!document.getElementById(elementID)) return false;
		var elem=document.getElementById(elementID);
		var xpos=parseInt(elem.style.left);
		var ypos=parseInt(elem.style.top);
		r.innerHTML=xpos+&quot;:&quot;+ypos;
		if(xpos==final_x&amp;&amp;ypos==final_y){
			return false;
		}
		if(xpos&lt;final_x){
		var dist=Math.ceil((final_x-xpos)/10)
			xpos=xpos+dist;
		}
		if(xpos&gt;final_x){
		var dist=Math.ceil((xpos-final_x)/10)
			xpos=xpos-dist;
		}
		if(ypos&lt;final_y){
	     var dist=Math.ceil((final_y-ypos)/10)
		  ypos=ypos+dist;
		}
		if(ypos&gt;final_y){
			var dist=Math.ceil((ypos-final_y)/10)
		  ypos=ypos-dist;
		}
		elem.style.left=xpos+&quot;px&quot;;
		elem.style.top=ypos+&quot;px&quot;;
		var repeat=&quot;moveElement('&quot;+elementID+&quot;',&quot;+final_x+&quot;,&quot;+final_y+&quot;,&quot;+interval+&quot;)&quot;;
		timer=setTimeout(repeat,interval);
	}
	var elem=document.getElementById(&quot;show&quot;);
	elem.style.position=&quot;absolute&quot;;
	elem.style.left=&quot;70px&quot;;
	elem.style.top=&quot;100px&quot;;
	document.getElementById(&quot;go&quot;).onclick=function(){
	  if(timer){
	  clearTimeout(timer);
	  }
		moveElement(&quot;show&quot;,1017,100,40);
	     store=function(){
		 moveElement(&quot;show&quot;,1017,100,40);
		 }
	}
	document.getElementById(&quot;stop&quot;).onclick=function(){
	if(timer){
	  clearTimeout(timer);
	  }
		moveElement(&quot;show&quot;,100,525,40);
		store=function(){
		 moveElement(&quot;show&quot;,100,525,40);
		 }
	}
	document.getElementById(&quot;pause&quot;).onclick=function(){
	if(timer){
	  clearTimeout(timer);
	  }
	}
	document.getElementById(&quot;goon&quot;).onclick=function(){
	store();
	}
&lt;/script&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_4eOkOy');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_4eOkOy');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_4eOkOy','runcode_4eOkOy');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>23、:</strong><br />
续写。。</p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=339" title="各种html+CSS实例效果 更新为2010.7.27">各种html+CSS实例效果 更新为2010.7.27</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1270" title="各种jquery实例效果">各种jquery实例效果</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=945" title="各种Javascript技巧">各种Javascript技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=680" title="最常用的十个javascript自定义函数">最常用的十个javascript自定义函数</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1286" title="各种jQuery技巧">各种jQuery技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1284" title="javascript字符串反转">javascript字符串反转</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1203" title="10个javascript Frameworks 外连">10个javascript Frameworks 外连</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1122" title="物体碰撞反弹与圆周运动">物体碰撞反弹与圆周运动</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1104" title="百度2010校园招聘前端开发笔试题">百度2010校园招聘前端开发笔试题</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=1099" title="08年阿里巴巴前端开发面试题">08年阿里巴巴前端开发面试题</a> (6)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=341</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>老爷爷我想你</title>
		<link>http://www.hemin.cn/blog/?p=1368</link>
		<comments>http://www.hemin.cn/blog/?p=1368#comments</comments>
		<pubDate>Sun, 18 Jul 2010 12:58:47 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[生活记载]]></category>
		<category><![CDATA[怀念]]></category>
		<category><![CDATA[老爷爷]]></category>
		<category><![CDATA[长大]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1368</guid>
		<description><![CDATA[我记得小时候周末去邻居家玩，看见有位老爷爷再给我们邻居的几位小朋友教课，我在门口看着，然后老爷爷也叫我进来听，经常讲些智力题，很有趣，他是每周循环到每个家里呆一次来讲课。我印象最深的是有一个智力题也是只有我一个人答对了。那个老爷爷很鼓励我。所以我留恋到现在，（题目是有一天小明早上读书的时候，请问他读的第一个字是什么字。）那个时候真的很激动。还有一次答题，答案是写在纸上，是关于将来的命运的。后来感觉只有我是答错了。那位老爷爷带我去一个房子里说了些话，说我以后命运会很好。呵呵。我心里的乐得啊。后来因为迷恋了智力题我每当无聊的时候就跑到附近的小书店看那个十万个为什么，还有相关的智力题。很有趣。嘿嘿。后来不知道为什么，老爷爷没有来了。不知道那位老爷爷现在是否在。很想去看看他，好想告诉他，我长大了。。。 如果我可以活到80岁左右的话，我也会像你那样的。去教教小朋友，培养他们成才。 随机日志小偷 (3)妈妈告诉我的细节 (0)XHTML模块化布局 (16)浅议 Web 表单设计 (1)随写08年腾讯面试题(实习生) (17)jQuery性能优化 (1)CSS优先权的计算 (1)各种jquery实例效果 (0)入门JavaScript正则表达式 (0)php中session详解 (2)]]></description>
			<content:encoded><![CDATA[<p>我记得小时候周末去邻居家玩，看见有位老爷爷再给我们邻居的几位小朋友教课，我在门口看着，然后老爷爷也叫我进来听，经常讲些智力题，很有趣，他是每周循环到每个家里呆一次来讲课。我印象最深的是有一个智力题也是只有我一个人答对了。那个老爷爷很鼓励我。所以我留恋到现在，（题目是有一天小明早上读书的时候，请问他读的第一个字是什么字。）那个时候真的很激动。还有一次答题，答案是写在纸上，是关于将来的命运的。后来感觉只有我是答错了。那位老爷爷带我去一个房子里说了些话，说我以后命运会很好。呵呵。我心里的乐得啊。后来因为迷恋了智力题我每当无聊的时候就跑到附近的小书店看那个十万个为什么，还有相关的智力题。很有趣。嘿嘿。后来不知道为什么，老爷爷没有来了。不知道那位老爷爷现在是否在。很想去看看他，好想告诉他，我长大了。。。<br />
<span id="more-1368"></span><br />
如果我可以活到80岁左右的话，我也会像你那样的。去教教小朋友，培养他们成才。</p>
<h3  class="related_post_title">随机日志</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=391" title="做网站和客户谈报价">做网站和客户谈报价</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=932" title="自我惭愧[巧遇]">自我惭愧[巧遇]</a> (9)</li><li><a href="http://www.hemin.cn/blog/?p=1213" title="关于一个布局的写法">关于一个布局的写法</a> (5)</li><li><a href="http://www.hemin.cn/blog/?p=880" title="入门JavaScript正则表达式">入门JavaScript正则表达式</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1099" title="08年阿里巴巴前端开发面试题">08年阿里巴巴前端开发面试题</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=1022" title="各种jQuery插件">各种jQuery插件</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1365" title="你身边有几个这样的朋友？">你身边有几个这样的朋友？</a> (2)</li><li><a href="http://www.hemin.cn/blog/?p=1154" title="互联网免费模式">互联网免费模式</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=270" title="CSS居中问题">CSS居中问题</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=945" title="各种Javascript技巧">各种Javascript技巧</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1368</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>你身边有几个这样的朋友？</title>
		<link>http://www.hemin.cn/blog/?p=1365</link>
		<comments>http://www.hemin.cn/blog/?p=1365#comments</comments>
		<pubDate>Thu, 08 Jul 2010 05:46:33 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[生活记载]]></category>
		<category><![CDATA[朋友]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1365</guid>
		<description><![CDATA[你身边有几个这样的朋友？ 没事就打打电话联系联系你说说话 没事就叫你一起去玩玩 没事就叫你一起吃吃饭 遇到悲伤的事情会找你聊聊，遇到高兴的事情会找你聊聊，遇到奇怪的事情会找你聊聊。 我们对彼此没有任何利益，目的，阴谋。 我们说话很随便，不会刻意去装，去虚伪。（我发现太多人喜欢装，喜欢虚伪。哎） 我们不是拜金主义，彼此有钱无钱不重要。 最近的感慨，除了亲人身边还有几个这样的朋友呢？ 随机日志找工作和找对象 (14)寻找博客开发合作伙伴 (3)最常用的十个javascript自定义函数 (1)表格小知识 (0)各种jQuery插件 (0)CSS查找匹配原理和简洁高效 (1)JavaScript 快速组合算法 (0)haslayout 综合介绍 (2)jQuery性能优化 (1)2007年韩国最感人的MV (2)]]></description>
			<content:encoded><![CDATA[<p>你身边有几个这样的朋友？<br />
没事就打打电话联系联系你说说话<br />
没事就叫你一起去玩玩<br />
没事就叫你一起吃吃饭<br />
遇到悲伤的事情会找你聊聊，遇到高兴的事情会找你聊聊，遇到奇怪的事情会找你聊聊。<br />
我们对彼此没有任何利益，目的，阴谋。<br />
我们说话很随便，不会刻意去装，去虚伪。（我发现太多人喜欢装，喜欢虚伪。哎）<br />
我们不是拜金主义，彼此有钱无钱不重要。</p>
<p>最近的感慨，除了亲人身边还有几个这样的朋友呢？</p>
<h3  class="related_post_title">随机日志</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=1191" title="PHP程序常见漏洞攻击分析">PHP程序常见漏洞攻击分析</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=339" title="各种html+CSS实例效果 更新为2010.7.27">各种html+CSS实例效果 更新为2010.7.27</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=860" title="WordPress常用PHP调用代码">WordPress常用PHP调用代码</a> (3)</li><li><a href="http://www.hemin.cn/blog/?p=388" title="谈网站建设的价格">谈网站建设的价格</a> (3)</li><li><a href="http://www.hemin.cn/blog/?p=37" title="练习迅雷面试题">练习迅雷面试题</a> (19)</li><li><a href="http://www.hemin.cn/blog/?p=1284" title="javascript字符串反转">javascript字符串反转</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1131" title="博客用户体验之未来发展">博客用户体验之未来发展</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=703" title="javascript替换字符">javascript替换字符</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1093" title="梦到某人了">梦到某人了</a> (2)</li><li><a href="http://www.hemin.cn/blog/?p=544" title="CSS Sprites图片合并">CSS Sprites图片合并</a> (4)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1365</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>tudou首页图片延迟加载</title>
		<link>http://www.hemin.cn/blog/?p=1354</link>
		<comments>http://www.hemin.cn/blog/?p=1354#comments</comments>
		<pubDate>Tue, 06 Jul 2010 19:04:09 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[JS/JQuery]]></category>
		<category><![CDATA[JQ]]></category>
		<category><![CDATA[tudou]]></category>
		<category><![CDATA[加载]]></category>
		<category><![CDATA[延迟]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1354</guid>
		<description><![CDATA[经常上tudou网，发现tudou首页加载图片的功能很有意思，tudou首页从&#8221;娱乐&#8221;这个板块往下的所有视频的缩略图并不是在页面打开后就加载的，而是当用户拖动滚动条到了&#8221;娱乐&#8221;这个板块，才开始加载图片的。 这样做的好处当然是如果有用户不需要查看下面的内容，则免去了下面所有图片的请求，这对减少服务器的压力还是很有帮助的。 其实tudou的实现原理很简单， 1.先把所有需要延迟加载的图片的src都设置成同1个小图片的连接(sprite.gif)，把真真图片的连接放进图片的alt属性中，look下代码： &#60;a class=&#34;inner&#34; target=&#34;new&#34; title=&#34;史上最重街舞选手和最柔软街舞选手&#34; href=&#34;http://www.tudou.com/programs/view/Utmt1_6Z-lU/&#34;&#62; &#60;img width=&#34;120&#34; height=&#34;90&#34; class=&#34;pack_clipImg lazyImg&#34; alt=&#34;http://i01.img.tudou.com/data/imgs/i/051/720/095/p.jpg&#34; src=&#34;http://css.tudouui.com/skin/__g/img/sprite.gif&#34; coords=&#34;_DAA&#34;/&#62; &#60;/a&#62; 2. 绑定window.scroll事件，在该事件里面的重设所有class为lazyImg的图片的src值，在土豆首页找到如下JS: var o=function(){ var s=TUI.pos.scrollTop(),q=c; if(q.box[0]){&#160;&#160; &#160;var r=q.box.offset().top;&#160;&#160; &#160;if(r-s&#62;0&#38;&#38;r-TUI.pos.windowHeight()&#60;s){&#160;&#160; &#160; &#160; &#160;q.init();&#160;&#160; &#160;}else{&#160;&#160; &#160; &#160; &#160;q.stop();&#160;&#160; &#160; &#160; &#160;}} if(!h&#124;&#124;s&#60;590){&#160;&#160; &#160;return true;} TUI.widget.quickPlaylist.load(); h=false }; o(); $(window).bind(&#34;scroll&#34;,o); 我没有去跟入查看TUI.widget.quickPlaylist.load()方法的实现，tudou的JS都是压缩混淆的，看起来挺累，不过大家知道原理就可以了。 实例： 上面说了那么多，最后还是来个实例比较实际点，毕竟眼见为实嘛。 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 [...]]]></description>
			<content:encoded><![CDATA[<p>经常上tudou网，发现tudou首页加载图片的功能很有意思，tudou首页从&#8221;娱乐&#8221;这个板块往下的所有视频的缩略图并不是在页面打开后就加载的，而是当用户拖动滚动条到了&#8221;娱乐&#8221;这个板块，才开始加载图片的。<br />
这样做的好处当然是如果有用户不需要查看下面的内容，则免去了下面所有图片的请求，这对减少服务器的压力还是很有帮助的。<br />
其实tudou的实现原理很简单，<br />
<span id="more-1354"></span><br />
1.先把所有需要延迟加载的图片的src都设置成同1个小图片的连接(sprite.gif)，把真真图片的连接放进图片的alt属性中，look下代码： </p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">a</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">inner</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">target</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">new</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">title</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">史上最重街舞选手和最柔软街舞选手</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">href</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://www.tudou.com/programs/view/Utmt1_6Z-lU/</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"> <br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">img</span><span style="color: Gray;"> </span><span style="color: #00008b;">width</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">120</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">height</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">90</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">pack_clipImg lazyImg</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">alt</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://i01.img.tudou.com/data/imgs/i/051/720/095/p.jpg</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">src</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://css.tudouui.com/skin/__g/img/sprite.gif</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">coords</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">_DAA</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> <br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">a</span><span style="color: Olive;">&gt;</span></div>
</div>
<p>2. 绑定window.scroll事件，在该事件里面的重设所有class为lazyImg的图片的src值，在土豆首页找到如下JS: </p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">o</span><span style="color: Gray;">=</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;"> <br /></span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">s</span><span style="color: Gray;">=</span><span style="color: Blue;">TUI</span><span style="color: Gray;">.</span><span style="color: Blue;">pos</span><span style="color: Gray;">.</span><span style="color: Blue;">scrollTop</span><span style="color: Olive;">()</span><span style="color: Gray;">,</span><span style="color: Blue;">q</span><span style="color: Gray;">=</span><span style="color: Blue;">c</span><span style="color: Gray;">; <br /></span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Blue;">q</span><span style="color: Gray;">.</span><span style="color: Blue;">box</span><span style="color: Olive;">[</span><span style="color: Maroon;">0</span><span style="color: Olive;">]){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">r</span><span style="color: Gray;">=</span><span style="color: Blue;">q</span><span style="color: Gray;">.</span><span style="color: Blue;">box</span><span style="color: Gray;">.</span><span style="color: Blue;">offset</span><span style="color: Olive;">()</span><span style="color: Gray;">.</span><span style="color: Blue;">top</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Blue;">r</span><span style="color: Gray;">-</span><span style="color: Blue;">s</span><span style="color: Gray;">&gt;</span><span style="color: Maroon;">0</span><span style="color: Gray;">&amp;&amp;</span><span style="color: Blue;">r</span><span style="color: Gray;">-</span><span style="color: Blue;">TUI</span><span style="color: Gray;">.</span><span style="color: Blue;">pos</span><span style="color: Gray;">.</span><span style="color: Blue;">windowHeight</span><span style="color: Olive;">()</span><span style="color: Gray;">&lt;</span><span style="color: Blue;">s</span><span style="color: Olive;">){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">q</span><span style="color: Gray;">.</span><span style="color: Blue;">init</span><span style="color: Olive;">()</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Green;">else</span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">q</span><span style="color: Gray;">.</span><span style="color: Blue;">stop</span><span style="color: Olive;">()</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Olive;">}</span><span style="color: Gray;"> <br /></span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Gray;">!</span><span style="color: Blue;">h</span><span style="color: Gray;">||</span><span style="color: Blue;">s</span><span style="color: Gray;">&lt;</span><span style="color: Maroon;">590</span><span style="color: Olive;">){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">true</span><span style="color: Gray;">;<br /></span><span style="color: Olive;">}</span><span style="color: Gray;"> <br /></span><span style="color: Blue;">TUI</span><span style="color: Gray;">.</span><span style="color: Blue;">widget</span><span style="color: Gray;">.</span><span style="color: Blue;">quickPlaylist</span><span style="color: Gray;">.</span><span style="color: Blue;">load</span><span style="color: Olive;">()</span><span style="color: Gray;">; <br /></span><span style="color: Blue;">h</span><span style="color: Gray;">=</span><span style="color: Green;">false</span><span style="color: Gray;"> <br /></span><span style="color: Olive;">}</span><span style="color: Gray;">; <br /></span><span style="color: Blue;">o</span><span style="color: Olive;">()</span><span style="color: Gray;">; <br />$</span><span style="color: Olive;">(</span><span style="color: Teal;">window</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">bind</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">scroll</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span><span style="color: Blue;">o</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>我没有去跟入查看<span>TUI.widget.quickPlaylist.load()</span>方法的实现，tudou的JS都是压缩混淆的，看起来挺累，不过大家知道原理就可以了。<br />
实例：<br />
上面说了那么多，最后还是来个实例比较实际点，毕竟眼见为实嘛。 </p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_qHV2NV">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
&lt;title&gt;tudou首页图片延迟加载 hemin&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
能看的见到图片：&lt;img src=&quot;http://at-img4.tdimg.com/board/2010/5/tylc-115X55.jpg&quot;/&gt;
&lt;div id=&quot;lazyBox&quot; style=&quot;margin-top:100px;&quot;&gt; 一开始看不到的图片：
&lt;img width=&quot;120&quot; height=&quot;90&quot; style=&quot;border:1px solid blue;&quot; class=&quot;lazyImg&quot; alt=&quot;http://i01.img.tudou.com/data/imgs/i/051/720/095/p.jpg&quot; src=&quot;http://css.tudouui.com/skin/__g/img/sprite.gif&quot; coords=&quot;_DAA&quot;/&gt;
&lt;img width=&quot;120&quot; height=&quot;90&quot; style=&quot;border:1px solid blue;&quot; class=&quot;lazyImg&quot; alt=&quot;http://i01.img.tudou.com/data/imgs/i/051/871/396/m20.jpg&quot; src=&quot;http://css.tudouui.com/skin/__g/img/sprite.gif&quot; coords=&quot;_DBA&quot;/&gt; &lt;/div&gt;
&lt;div style=&quot;height:1000px;&quot;&gt; &lt;/div&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var hasShow = false;
$(window).bind(&quot;scroll&quot;,function(){
	if(hasShow == true){
		$(window).unbind(&quot;scroll&quot;);
		return;
	}
	var t = $(document).scrollTop();
	if(t &gt; 50){
		// 滚动高度超过50，加载图片
		hasShow = true;
		$(&quot;#lazyBox .lazyImg&quot;).each(function(){
			$(this).attr(&quot;src&quot;,$(this).attr(&quot;alt&quot;)).removeAttr(&quot;alt&quot;);
		});
	}
});
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_qHV2NV');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_qHV2NV');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_qHV2NV','runcode_qHV2NV');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=1270" title="各种jquery实例效果">各种jquery实例效果</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1313" title="jQuery性能优化">jQuery性能优化</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1286" title="各种jQuery技巧">各种jQuery技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1068" title="我推荐的书籍">我推荐的书籍</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1022" title="各种jQuery插件">各种jQuery插件</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=984" title="JQ模块库09.12.08">JQ模块库09.12.08</a> (35)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1354</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>各种jquery实例效果</title>
		<link>http://www.hemin.cn/blog/?p=1270</link>
		<comments>http://www.hemin.cn/blog/?p=1270#comments</comments>
		<pubDate>Tue, 06 Jul 2010 10:16:04 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[JS/JQuery]]></category>
		<category><![CDATA[JQ]]></category>
		<category><![CDATA[实例]]></category>
		<category><![CDATA[收藏]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1270</guid>
		<description><![CDATA[新增实例：淡入淡出选项卡，文字立体渐变； 这里收集和原创各种jquery实例效果。（为了工作需要和学习得更多） 1、仿迅雷首页视频展示 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62; &#60;title&#62;仿迅雷首页视频展示JQ版 hemin&#60;/title&#62; &#60;link href=&#34;style.css&#34; rel=&#34;stylesheet&#34; type=&#34;text/css&#34; /&#62; &#60;style type=&#34;text/css&#34;&#62; * { margin:0; padding:0; word-break:break-all; } body { background:#FFF; color:#333; font:12px/1.5em Helvetica, Arial, sans-serif; } h1, h2, h3, h4, h5, h6 { font-size:1em; } a { color:#2B93D2; [...]]]></description>
			<content:encoded><![CDATA[<div style="font-size:14px;text-decoration:underline;">新增实例：<span style="color:#F00">淡入淡出选项卡，文字立体渐变；</span></div>
<p>这里收集和原创各种jquery实例效果。（为了工作需要和学习得更多）</p>
<p><strong>1、仿迅雷首页视频展示</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_h8ser4">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;仿迅雷首页视频展示JQ版   hemin&lt;/title&gt;
&lt;link href=&quot;style.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
&lt;style type=&quot;text/css&quot;&gt;
* { margin:0; padding:0; word-break:break-all; }
body { background:#FFF; color:#333; font:12px/1.5em Helvetica, Arial, sans-serif; }
h1, h2, h3, h4, h5, h6 { font-size:1em; }
a { color:#2B93D2; text-decoration:none; }
a:hover { color:#E31E1C; text-decoration:underline; }
ul, li { list-style:none; }
fieldset, img { border:none; }
/* v_show style */
.v_show { width:595px; margin:20px 0 1px 60px; }
.v_caption { height:35px; overflow:hidden; background:url(http://www.hemin.cn//Photo/btn_cartoon.gif) no-repeat 0 0; }
.v_caption h2 { float:left; width:84px; height:35px; overflow:hidden; background:url(http://www.hemin.cn//Photo/btn_cartoon.gif) no-repeat; text-indent:-9999px; }
.v_caption .cartoon { background-position: 0 -100px; }
.v_caption .variety { background-position:-100px -100px; }
.highlight_tip { display:inline; float:left; margin:14px 0 0 10px; }
.highlight_tip span { display:inline; float:left; width:7px; height:7px; overflow:hidden; margin:0 2px; background:url(http://www.hemin.cn//Photo/btn_cartoon.gif) no-repeat 0 -320px; text-indent:-9999px; cursor:pointer; }
.highlight_tip .current { background-position:0 -220px; }
.change_btn { float:left; margin:7px 0 0 10px; }
.change_btn span { display:block; float:left; width:30px; height:23px; overflow:hidden; background:url(http://www.hemin.cn//Photo/btn_cartoon.gif) no-repeat; text-indent:-9999px; cursor:pointer; }
.change_btn .prev { background-position:0 -400px;  }
.change_btn .next { width:31px; background-position:-30px -400px; }
.v_caption em { display:inline; float:right; margin:10px 12px 0 0; font-family:simsun; }
.v_content { position:relative; width:592px; height:160px; overflow:hidden; border-right:1px solid #E7E7E7; border-bottom:1px solid #E7E7E7; border-left:1px solid #E7E7E7; }
.v_content_list { position:absolute; width:2500px;top:0px; left:0px; }
.v_content ul {float:left;}
.v_content ul li { display:inline; float:left; margin:10px 0px 0; padding:10px; background:url(http://www.hemin.cn//Photo/v_bg.gif) no-repeat; }
.v_content ul li a { display:block; width:128px; height:80px; overflow:hidden; }
.v_content ul li img {  width:128px; height:96px; }
.v_content ul li h4 { width:128px; height:18px; overflow:hidden; margin-top:12px; font-weight:normal; }
.v_content ul li h4 a { display:inline !important; height:auto !important; }
.v_content ul li span { color:#666; }
.v_content ul li em { color:#888; font-family:Verdana; font-size:0.9em; }
.ccc{ background-color:#ccc!important;}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
	var page = 1;
	var i = 4;
	$('.v_content_list li').click(function(){
			$(this).addClass(&quot;ccc&quot;).siblings().removeClass(&quot;ccc&quot;);
		});
	$('.highlight_tip span').click(function(){
			var $index = $('.highlight_tip span').index(this);
			$('.highlight_tip span').eq($index).addClass(&quot;current&quot;).siblings().removeClass(&quot;current&quot;);
			if(!$('.v_content_list').is(&quot;:animated&quot;)){
				if($index == 0){
					$('.v_content_list').animate({left:'0px'},&quot;slow&quot;);page = 1;
					}else if($index == 1){
							$('.v_content_list').animate({left:'-592px'},&quot;slow&quot;);page = 2;
						}else if($index == 2){
								$('.v_content_list').animate({left:'-1184px'},&quot;slow&quot;);page = 3;
							}else if($index == 3){
									$('.v_content_list').animate({left:'-1776px'},&quot;slow&quot;);page = 4;
								}
			}
		});
	$('span.next').click(function(){
			var $parent = $(this).parents(&quot;div.v_show&quot;);
			var $v_show = $parent.find(&quot;div.v_content_list&quot;);
			var $v_content = $parent.find(&quot;div.v_content&quot;);
			var v_width = $v_content.width();
			var len = $v_show.find(&quot;li&quot;).length;
			var page_count = Math.ceil(len / i);
			if(!$v_show.is(&quot;:animated&quot;)){
				if(page == page_count){
						$v_show.animate({left:'0px'},&quot;slow&quot;);
						page = 1;
					}else{
						$v_show.animate({left:'-='+v_width},&quot;slow&quot;);
						page++;
					}
			}
			$parent.find(&quot;span&quot;).eq((page-1)).addClass(&quot;current&quot;).siblings().removeClass(&quot;current&quot;);
	});
	$('span.prev').click(function(){
			var $parent = $(this).parents(&quot;div.v_show&quot;);
			var $v_show = $parent.find(&quot;div.v_content_list&quot;);
			var $v_content = $parent.find(&quot;div.v_content&quot;);
			var v_width = $v_content.width();
			var len = $v_show.find(&quot;li&quot;).length;
			var page_count = Math.ceil(len / i);
			if(!$v_show.is(&quot;:animated&quot;)){
				if(page == 1){
						$v_show.animate({ left : '-='+v_width*(page_count-1) }, &quot;slow&quot;);
						page = page_count;
					}else{
						$v_show.animate({left:'+='+v_width},&quot;slow&quot;);
						page--;
					}
			}
			$parent.find(&quot;span&quot;).eq((page-1)).addClass(&quot;current&quot;).siblings().removeClass(&quot;current&quot;);
	});
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;v_show&quot;&gt;
	&lt;div class=&quot;v_caption&quot;&gt;
		&lt;h2 class=&quot;cartoon&quot; title=&quot;卡通动漫&quot;&gt;卡通动漫&lt;/h2&gt;
		&lt;div class=&quot;highlight_tip&quot;&gt;
			&lt;span class=&quot;current&quot;&gt;1&lt;/span&gt;&lt;span&gt;2&lt;/span&gt;&lt;span&gt;3&lt;/span&gt;&lt;span&gt;4&lt;/span&gt;
		&lt;/div&gt;
		&lt;div class=&quot;change_btn&quot;&gt;
			&lt;span class=&quot;prev&quot; &gt;上一页&lt;/span&gt;
			&lt;span class=&quot;next&quot;&gt;下一页&lt;/span&gt;
		&lt;/div&gt;
		&lt;em&gt;&lt;a href=&quot;#&quot;&gt;更多&gt;&gt;&lt;/a&gt;&lt;/em&gt;
	&lt;/div&gt;
	&lt;div class=&quot;v_content&quot;&gt;
		&lt;div  class=&quot;v_content_list&quot;&gt;
			&lt;ul&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/01.jpg&quot; alt=&quot;海贼王&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;海贼王&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;28,276&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/01.jpg&quot; alt=&quot;海贼王&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;海贼王&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;28,276&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/01.jpg&quot; alt=&quot;海贼王&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;海贼王&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;28,276&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/01.jpg&quot; alt=&quot;海贼王&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;海贼王&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;28,276&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/02.jpg&quot; alt=&quot;哆啦A梦&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;哆啦A梦&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;33,326&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/02.jpg&quot; alt=&quot;哆啦A梦&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;哆啦A梦&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;33,326&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/02.jpg&quot; alt=&quot;哆啦A梦&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;哆啦A梦&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;33,326&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/02.jpg&quot; alt=&quot;哆啦A梦&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;哆啦A梦&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;33,326&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/03.jpg&quot; alt=&quot;火影忍者&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;火影忍者&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;28,276&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/03.jpg&quot; alt=&quot;火影忍者&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;火影忍者&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;28,276&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/03.jpg&quot; alt=&quot;火影忍者&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;火影忍者&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;28,276&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/03.jpg&quot; alt=&quot;火影忍者&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;火影忍者&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放:&lt;em&gt;28,276&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/04.jpg&quot; alt=&quot;龙珠&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;龙珠&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放 &lt;em&gt;57,865&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/04.jpg&quot; alt=&quot;龙珠&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;龙珠&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放 &lt;em&gt;57,865&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/04.jpg&quot; alt=&quot;龙珠&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;龙珠&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放 &lt;em&gt;57,865&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.hemin.cn//Photo/04.jpg&quot; alt=&quot;龙珠&quot; /&gt;&lt;/a&gt;&lt;h4&gt;&lt;a href=&quot;#&quot;&gt;龙珠&lt;/a&gt;&lt;/h4&gt;&lt;span&gt;播放 &lt;em&gt;57,865&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;
		     &lt;/ul&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_h8ser4');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_h8ser4');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_h8ser4','runcode_h8ser4');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>ps:一直想访迅雷首页那个视频展示的，今天就有时间访了一下，参考的锋利的JQuery书里面找到第四章的案例，再那案例里面增加了一点小功能。2010.7.1<br />
<span id="more-1270"></span></p>
<p><strong>2、按字母顺序分类导航</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_YLLG9B">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;按字母顺序分类导航 －－ hemin jq版&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
	*{ margin:0;padding:0;}
	body{ font:normal 12px Verdana, Arial, Helvetica, sans-serif; text-align:center;}
	#warpper{ position:absolute; left:100px; top:100px;}
	h4{ padding-left:5px; float:left;}
	a{ text-decoration:underline; font-weight:bold;}
	dl{ height:18px; line-height:18px; background:#f7f7f7;  border:1px solid #ccc; border-right:0;}
	dt,.normal{ position:relative; float:left; padding:0 5px; border-right:1px solid #ccc; text-decoration:none; width:14px; cursor:pointer;}
	dt.over{ border:1px solid #86e5f0; padding:0 5px 15px; border-bottom:1px solid #caf1f1; margin:-1px 0 0 -1px; z-index:1000; color:#ff6026; background:#caf1f1; height:9px; }
	ul{ overflow:hidden;}
	li{ float:left; list-style-type:none; margin:5px 10px; width:120px;}
	li a{ color:#000;}
	dl dd{ position:absolute; width:719px; left:-1px;top:24px!important; border:1px solid #86e5f0; background:#caf1f1; padding:10px 0;}
	#tooltip{margin-top:-40px;margin-left:-1px;display:none;color:#336699; }
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	$(function(){
			var $dt = $('#warpper dt');
			var $dd = $('#warpper dd');
			$dd.hide();
			for(var i = 0; i &lt; $dd.length; i++){
				//扫描dd有多少个。
				var this_zero = $dd.eq(i).find(&quot;ul&quot;).find(&quot;li&quot;).length;
				if(this_zero == 0){
					$dt.eq(i).css(&quot;color&quot;,&quot;#ccc&quot;);
				}
			}
			$dt.mouseover(function(e){
					var $index = $dt.index(this);
					var $this_dt = $dt.eq($index);
					var $this_dd = $dd.eq($index);
					var myNumber = $this_dd.find(&quot;ul&quot;).find(&quot;li&quot;).length;
					var tooltip = &quot;&lt;div id='tooltip'&gt;&quot;+myNumber+&quot;&lt;/div&gt;&quot;;
					$this_dt.append(tooltip);
					$('#tooltip').show();
					$this_dt.addClass(&quot;over&quot;).siblings(&quot;dt&quot;).removeClass(&quot;over&quot;);
					$this_dd.show().siblings(&quot;dd&quot;).hide();
				}).mouseout(function(){
						$('#tooltip').remove();
					});
		})
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;dl id=&quot;warpper&quot;&gt;
    &lt;h4&gt;拼音检索：&lt;/h4&gt;
    &lt;dt&gt;a&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Adidas&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;AEE/爱意&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;AF&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;AF棒球帽&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Agatha&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Albion/奥尔滨&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;AMD&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Andox&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Artini&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;爱普生&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;b&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;c&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fdsfas&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;d&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fdsfas&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdffsd&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;e&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fdsfas&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdffsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdfsaf&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;f&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏贺贺敏贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;g&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;h&lt;/dt&gt;
    &lt;dd&gt;No matching entries&lt;/dd&gt;
    &lt;dt&gt;i&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fdsfas&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdffsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdfsaf&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;j&lt;/dt&gt;
    &lt;dd&gt;No matching entries&lt;/dd&gt;
    &lt;dt&gt;k&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏贺敏贺贺&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;l&lt;/dt&gt;
    &lt;dd&gt;No matching entries&lt;/dd&gt;
    &lt;dt&gt;m&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;n&lt;/dt&gt;
    &lt;dd&gt;No matching entries&lt;/dd&gt;
    &lt;dt&gt;o&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fdsfas&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdffsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdfsaf&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;p&lt;/dt&gt;
    &lt;dd&gt;No matching entries&lt;/dd&gt;
    &lt;dt&gt;q&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏贺敏贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;r&lt;/dt&gt;
    &lt;dd&gt;No matching entries&lt;/dd&gt;
    &lt;dt&gt;s&lt;/dt&gt;
    &lt;dd&gt;No matching entries&lt;/dd&gt;
    &lt;dt&gt;t&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;u&lt;/dt&gt;
    &lt;dd&gt;No matching entries&lt;/dd&gt;
    &lt;dt&gt;v&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fdsfas&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdffsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdfsaf&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;w&lt;/dt&gt;
    &lt;dd&gt;No matching entries&lt;/dd&gt;
    &lt;dt&gt;x&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasfs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fsdfsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fdsfas&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdffsd&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;fasdfsaf&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
    &lt;dt&gt;y&lt;/dt&gt;
    &lt;dd&gt;No matching entries&lt;/dd&gt;
    &lt;dt&gt;z&lt;/dt&gt;
    &lt;dd&gt;
        &lt;ul&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏贺贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;贺敏贺敏&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Fancl&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/dd&gt;
&lt;/dl&gt;
&lt;a href=&quot;http://www.hemin.cn/blog&quot;&gt;http://www.hemin.cn/blog&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_YLLG9B');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_YLLG9B');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_YLLG9B','runcode_YLLG9B');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>ps:下午碰巧在蓝色逛了下，雅兴写了个JQ版的《按字母顺序分类导航》。2010.6.23</p>
<p><strong>3、手风琴竖向菜单</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_7yzyar">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;jQuery 手风琴竖向菜单&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
* {margin:0; padding:0}
#accordion {width:259px; margin:50px auto; border:1px solid #333; border-top:none}
.accordion {width:259px; font:12px Verdana, Arial; color:#333}
.accordion dt {width:247px; padding:4px 6px; font-weight:bold; cursor:pointer; background-color:#666; background-image:url(images/arrow_down.gif); background-position: right center; background-repeat:no-repeat; color:#fff; border-top: 1px solid #333}
.accordion dt:hover {background-color:#555}
.accordion .open {background-color:#444; background-image:url(images/arrow_up.gif)}
.accordion dd {overflow:hidden; background:#fff; display:0;}
.accordion dd div { width:229px; border-top:none; padding:15px}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
		$('#slider dd:eq(1),#slider dd:eq(2),#slider dd:eq(3)').css({height:0,display:&quot;none&quot;});
		$('#slider dt:first').addClass(&quot;open&quot;);
		$('#slider dd:first').css({display:&quot;block&quot;});
		var $dt = $('#slider dt');
		var $dd = $('#slider dd');
		$dt.click(
			function(){
					var $index = $dt.index(this);
					var $this_dt = $dt.eq($index);
					var $this_dd = $dd.eq($index);
					if($this_dd.css(&quot;display&quot;) == (&quot;block&quot;)){ //判断dd是否显示
						$this_dt.removeClass(&quot;open&quot;);
						$this_dd.animate({height:0,opacity:0,},600,function(){$(this).css(&quot;display&quot;,&quot;none&quot;);});
					}else{
						var $div_h = $this_dd.css(&quot;display&quot;,&quot;block&quot;).find(&quot;div&quot;).innerHeight();
						$this_dt.addClass(&quot;open&quot;).siblings(&quot;dt&quot;).removeClass(&quot;open&quot;);
						$this_dd.animate({height:&quot;+&quot;+$div_h,opacity:1},600).siblings(&quot;dd&quot;).animate({height:0,opacity:0,},500,function(){$(this).css(&quot;display&quot;,&quot;none&quot;);});
					}
				}
		);
	});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;accordion&quot;&gt;
	&lt;dl id=&quot;slider&quot; class=&quot;accordion&quot;&gt;
		&lt;dt&gt;火影忍者&lt;/dt&gt;
		&lt;dd&gt;
			&lt;div&gt;
				从小身上封印着邪恶的九尾妖狐，无父无母的鸣人受尽了村里人的冷落，但是他却不知道原因，只是拼命用各种恶作剧试图吸引大家的注意力，
				人们却反而更远离他。好在还有依鲁卡老师关心他，
				&lt;img src=&quot;http://hiphotos.baidu.com/jonny1008/pic/item/16c65216d09434224a90a712.jpg&quot; width=&quot;100&quot; height=&quot;102&quot; alt=&quot;佩恩六道&quot; /&gt;
				&lt;img src=&quot;http://hiphotos.baidu.com/w2008wjay/pic/item/f4c1ad7a80acfbd72f73b349.jpg&quot; width=&quot;100&quot; height=&quot;100&quot; alt=&quot;漩涡鸣人&quot; /&gt;
				&lt;br/&gt;
				鸣人的性格才没有变得扭曲。他总是干劲十足，嘻嘻哈哈，超级乐观。为了让更多的人认可自己，
				鸣人的目标是——成为第六代火影！
			&lt;/div&gt;
		&lt;/dd&gt;
		&lt;dt&gt;天空之城&lt;/dt&gt;
		&lt;dd&gt;
			&lt;div&gt;
				故事发生的时间大概是十九世纪初，是个带有欧洲工业革命时期味道的年代，女孩希达被政府军软禁在飞艇上，灵敏的海盗们嗅到了希达身上不同一般人的身份，在深夜向飞艇发动了进攻，就在两方人马争夺西大的时候，慌乱逃跑的女孩不小心从飞艇上调了下去，可就在向着地面追落得时候，希达胸前的石头发出了耀眼的光芒，温柔的包围住希达，并慢慢落下地面，就在这时，矿工机师的徒弟巴斯在回程的路上看到了光芒中心的希达，并接下了她......&lt;br/&gt;
				&lt;img src=&quot;http://hiphotos.baidu.com/xlycy1/pic/item/293347d1c1ad4208960a167a.jpg&quot; width=&quot;220&quot; height=&quot;100&quot; alt=&quot;天空之城&quot; /&gt;
			&lt;/div&gt;
		&lt;/dd&gt;
		&lt;dt&gt;海贼王&lt;/dt&gt;
		&lt;dd&gt;
			&lt;div&gt;
				在某个海岛小渔村长大。和暂驻在渔村的大海盗红发杰克感情很好，于是一心想成为海盗。眼下的疤痕就是为了显示自己够狠自己用刀划的。可是路飞7岁时因为和杰克斗气糊里糊涂的吃了海盗们抢来的恶魔果实——橡皮果实（ゴムゴムの実），从此再也学不会游泳。&lt;br/&gt;
				&lt;img src=&quot;http://hiphotos.baidu.com/haigevsjunjie/pic/item/e6525c44bd65900ecefca3e9.jpg&quot; width=&quot;220&quot; height=&quot;100&quot; alt=&quot;海贼王&quot; /&gt;
			&lt;/div&gt;
		&lt;/dd&gt;
		&lt;dt&gt;死神&lt;/dt&gt;
		&lt;dd&gt;
			&lt;div&gt;
				主角是名叫黑崎一护的15岁高中生，是个热血少年。因一次被一种叫&quot;虚&quot;的怪物攻击时，认识了一个自称是死神的少女&quot;露琪亚&quot;。一护因为露琪亚给予了他力量而变成了死神，从此开始履行作为一个死神的职责--消灭虚...
				露琪亚将死神的力量传给人类这件事被尸魂界得知，于是朽木白哉和阿散井恋次被派到现世执行将露琪亚带回尸魂界并关押的任务（人物应该不用介绍吧~！）。露琪亚不想让一护卷进此事，于是孤身一人前去迎战，可是能力终究敌不上队长级的。就在危急关头，一护找到了露琪亚，并想阻止他们将其带走。但现在的一护毕竟不强，被朽木白哉连砍两刀，倒在血泊中。露琪亚含泪离开...	&lt;br/&gt;
				&lt;img src=&quot;http://hiphotos.baidu.com/zxcc1121/pic/item/de773508284dae0ae824886c.jpg&quot; width=&quot;220&quot; height=&quot;100&quot; alt=&quot;死神&quot; /&gt;
			&lt;/div&gt;
		&lt;/dd&gt;
	&lt;/dl&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_7yzyar');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_7yzyar');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_7yzyar','runcode_7yzyar');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>4、手风琴横向菜单</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode__BHaC_">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;title&gt;jQuery 手风琴横向菜单&lt;/title&gt;
&lt;/head&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;/normal.css&quot; /&gt;
&lt;style type=&quot;text/css&quot;&gt;
.wrapper_box {background-color:#FFFFFF;margin:0 auto;padding:8px 10px;width:916px;}
#imageMenu {height:421px;overflow:hidden;position:relative;width:916px;}
#imageMenu ul {display:block;height:421px;width:1500px;}
#imageMenu ul li {float:left;}
#imageMenu ul li a {background:#FFFFFF none no-repeat left top;border-right:5px solid #FFFFFF;cursor:pointer;display:block;height:421px;overflow:hidden;text-indent:-1000px;width:224px;}
#imageMenu ul li.stap1 a {background:#FFFFFF url(http://www.dshos.com/images/step1.jpg) no-repeat left top;}
#imageMenu ul li.stap2 a {background:#FFFFFF url(http://www.dshos.com/images/step2.jpg) no-repeat scroll left top;}
#imageMenu ul li.stap3 a {background:#FFFFFF url(http://www.dshos.com/images/step3.jpg) no-repeat scroll left top;}
#imageMenu ul li.stap4 a {background:#FFFFFF url(http://www.dshos.com/images/step4.jpg) no-repeat scroll left top;}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
var thisId;
$(function (){
	 var curimg;
	 $(&quot;#imageMenu li a&quot;).hover(start,clos);
	 })
	function start(){
		$(&quot;#imageMenu li a&quot;).stop(true);
		if(!$(this).is(&quot;:animated&quot;)){
			var $this=$(this);
			$(&quot;#imageMenu li a&quot;).animate({width:'48'},&quot;slow&quot;,null,function(){
				});
				thisId = $this.parent().attr(&quot;class&quot;);
				thisId = &quot;#&quot;+thisId;
				$this.animate({width:'759'},600).stop();
				showInfo(thisId);
				}
			}
	function clos(){
		$(&quot;#imageMenu li a&quot;).stop(true);
		$(&quot;#imageMenu li a&quot;).animate({width:'224'},600);
		$(&quot;#info&quot;).show();
		}
	function showInfo(hh){
		if(!$(this).is(&quot;:animated&quot;)){
			$(&quot;.contain_box div&quot;).hide(0,function(){$(hh).fadeIn(0);})
			}
		}
&lt;/script&gt;
&lt;body&gt;
&lt;div class=&quot;wrapper_box&quot;&gt;
	&lt;div id=&quot;imageMenu&quot;&gt;
    	&lt;ul&gt;
        	&lt;li class=&quot;stap1&quot;&gt;&lt;a href=&quot;/&quot;&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;li class=&quot;stap2&quot;&gt;&lt;a href=&quot;/&quot;&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;li class=&quot;stap3&quot;&gt;&lt;a href=&quot;/&quot;&gt;&lt;/a&gt;&lt;/li&gt;
            &lt;li class=&quot;stap4&quot;&gt;&lt;a href=&quot;/&quot;&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
    &lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode__BHaC_');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode__BHaC_');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode__BHaC_','runcode__BHaC_');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>ps:前几天在JS群里某人发了一个手风琴菜单，于是我就仿照玩玩。2010.6.22</p>
<p><strong>5、淡入淡出选项卡</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_unJci1">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;淡入淡出选项卡 hemin&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
ul,li {margin: 0;padding: 0;list-style: none;}
#tabfirst li {float: left;background-color: #868686;color: white;padding: 5px;margin-right: 2px;border: 1px solid white;}
#tabfirst li.tabin{background-color:#6E6E6E;border: 1px solid #6E6E6E;}
.contentfirst {clear: left;background-color:#6E6E6E;color: white;width: 300px;height: 100px;padding: 10px;display: none;}
.contentin {display: block;}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
 $(function(){
	 var $div_li =$(&quot;#tabfirst li&quot;);
	 $div_li.click(function(){
			var index =  $div_li.index(this);
			$(this).addClass(&quot;tabin&quot;).siblings().removeClass(&quot;tabin&quot;);
			setTimeout(function(){$('#tab_box &gt; div').eq(index).fadeIn()},400);
			$('#tab_box &gt; div').eq(index).siblings().fadeOut();
		 });
})
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;ul id=&quot;tabfirst&quot;&gt;
    &lt;li class=&quot;tabin&quot;&gt;标签1&lt;/li&gt;
    &lt;li&gt;标签2&lt;/li&gt;
    &lt;li&gt;标签3&lt;/li&gt;
&lt;/ul&gt;
&lt;div id=&quot;tab_box&quot;&gt;
    &lt;div class=&quot;contentin contentfirst&quot;&gt;我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 我是内容1 &lt;/div&gt;
    &lt;div class=&quot;contentfirst&quot;&gt;我是内容2 我是内容2  我是内容2  我是内容2  我是内容2 我是内容2 我是内容2 我是内容2 我是内容2 我是内容2 我是内容2 我是内容2 我是内容2 我是内容2 &lt;/div&gt;
    &lt;div class=&quot;contentfirst&quot;&gt;我是内容3 我是内容3 我是内容3 我是内容3 我是内容3 我是内容3 我是内容3 我是内容3 我是内容3 我是内容3 我是内容3 &lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_unJci1');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_unJci1');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_unJci1','runcode_unJci1');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>ps:本来昨天就想做一下的。后来因为去面试了，耽误了点时间。2010.7.6</p>
<p><strong>6、文字立体渐变</strong></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_cxOAHD">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;文字立体渐变&lt;/title&gt;
&lt;style type=&quot;text/css&quot; title=&quot;&quot;&gt;
body{background:#333}
.en{font-family:&quot;lucida grande&quot;,verdana,sans-serif;font-size:35px;}
.cn{font-family:黑体;font-size:50px;height:80px;overflow:hidden}
.rainbows{position:relative;display:block;}
.rainbow {background: transparent;display: block;position: relative;height: 1px;overflow: hidden;z-index: 5;}
.rainbow span {position: absolute;display: block;top: 0;left: 0px;}
.rainbows .highlight {color: #fff;display:block;position: absolute;top: -2px;left: 0px;z-index: 4;}
.rainbows .shadow {color: #000;display:block;position: absolute;opacity: 0.5;filter:alpha(opacity=50);top: 2px;left: 2px;z-index: 3;}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function initGradients(s) {
    $(function() {
        $(s).each(function() {
            var el = this;
            var from = $(el).attr('gradFromColor')||'#ffffff', to = $(el).attr('gradToColor')||'#000000';
            var fR = parseInt(from.substring(1, 3), 16),
            fG = parseInt(from.substring(3, 5), 16),
            fB = parseInt(from.substring(5, 7), 16),
            tR = parseInt(to.substring(1, 3), 16),
            tG = parseInt(to.substring(3, 5), 16),
            tB = parseInt(to.substring(5, 7), 16);
            var h = $(this).height() * 1.5;
            var html,cacheHTML=[];
            this.initHTML = html = this.initHTML||this.innerHTML;
            this.innerHTML = '';
            for (var i = 0; i &lt; h; i++) {
                var c = '#' + (Math.floor(fR * (h - i) / h + tR * (i / h))).toString(16) + (Math.floor(fG * (h - i) / h + tG * (i / h))).toString(16) + (Math.floor(fB * (h - i) / h + tB * (i / h))).toString(16);
                cacheHTML.push('&lt;span class=&quot;rainbow rainbow-' + i + '&quot; style=&quot;color: ' + c + ';&quot;&gt;&lt;span style=&quot;top: ' + ( - i - 1) + 'px;&quot;&gt;' + html + '&lt;/span&gt;&lt;/span&gt;')
            }
            cacheHTML.push('&lt;span class=&quot;highlight&quot;&gt;' + html + '&lt;/span&gt;','&lt;span class=&quot;shadow&quot;&gt;' + html + '&lt;/span&gt;');
            $(cacheHTML.join('')).appendTo(this)
        })
    })
}
initGradients('.rainbows');
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;span class=&quot;rainbows en&quot;&gt;&amp;copy; 2009 Dragon Interactive. All Rights Reserved.&lt;/span&gt; &lt;span class=&quot;rainbows cn&quot; gradToColor=&quot;#ff0000&quot;&gt;汉字测试：红色渐变&lt;/span&gt; &lt;span class=&quot;rainbows cn&quot; gradToColor=&quot;#00ff00&quot;&gt;汉字测试：绿色渐变&lt;/span&gt; &lt;span class=&quot;rainbows cn&quot; gradToColor=&quot;#0000ff&quot;&gt;汉字测试：蓝色渐变&lt;/span&gt; &lt;span class=&quot;rainbows cn&quot; gradToColor=&quot;#ffff00&quot;&gt;汉字测试：黄色渐变&lt;/span&gt; &lt;span class=&quot;rainbows cn&quot; gradToColor=&quot;#ff00ff&quot;&gt;汉字测试：粉色渐变&lt;/span&gt; &lt;span class=&quot;rainbows cn&quot; gradToColor=&quot;#00ffff&quot;&gt;汉字测试：浅绿渐变&lt;/span&gt; &lt;span class=&quot;rainbows cn&quot; gradFromColor=&quot;#000000&quot; gradToColor=&quot;#ffffff&quot;&gt;汉字测试：黑白渐变（不是从白色开始的渐变显示有点异常）&lt;/span&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_cxOAHD');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_cxOAHD');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_cxOAHD','runcode_cxOAHD');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>7、</strong></p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=339" title="各种html+CSS实例效果 更新为2010.7.27">各种html+CSS实例效果 更新为2010.7.27</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=341" title="各种javascript实例效果 更新为2010.07.26">各种javascript实例效果 更新为2010.07.26</a> (4)</li><li><a href="http://www.hemin.cn/blog/?p=1286" title="各种jQuery技巧">各种jQuery技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1022" title="各种jQuery插件">各种jQuery插件</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1354" title="tudou首页图片延迟加载">tudou首页图片延迟加载</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1313" title="jQuery性能优化">jQuery性能优化</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1068" title="我推荐的书籍">我推荐的书籍</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=984" title="JQ模块库09.12.08">JQ模块库09.12.08</a> (35)</li><li><a href="http://www.hemin.cn/blog/?p=945" title="各种Javascript技巧">各种Javascript技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=860" title="WordPress常用PHP调用代码">WordPress常用PHP调用代码</a> (3)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1270</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS查找匹配原理和简洁高效</title>
		<link>http://www.hemin.cn/blog/?p=1340</link>
		<comments>http://www.hemin.cn/blog/?p=1340#comments</comments>
		<pubDate>Mon, 05 Jul 2010 17:39:43 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[(x)Html/Css]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[匹配]]></category>
		<category><![CDATA[查找]]></category>
		<category><![CDATA[简洁]]></category>
		<category><![CDATA[高效]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1340</guid>
		<description><![CDATA[用了这么多年的CSS，现在才明白CSS的真正匹配原理，不知道你是否也跟我一样？ 先来看一个简单的CSS： DIV#divBox p span.red{color:red;}，按习惯我们对这个CSS 的理解是，浏览器先查找id为divBox的DIV元素，当找到后，再找其下的所有p元素，然后再查找所有span元素，当发现有span的class为red的时候，就应用该style。多么简单易懂的原理，可是这个理解却是完完全全相反、错误的。 匹配原理： 浏览器CSS匹配不是从左到右进行查找，而是从右到左进行查找。比如之前说的DIV#divBox p span.red{color:red;}， 浏览器的查找顺序如下： 先查找html中所有class=&#8217;red&#8217;的span元素，找到后，再查找其父辈元素中是否有p元素，再判断p的父元素中是否有id为divBox的div元素，如果都存在则匹配上。 浏览器从右到左进行查找的好处是为了尽早过滤掉一些无关的样式规则和元素。比如如下html和css: &#60;style type=&#34;text/css&#34;&#62; DIV#divBox p span.red{color:red;} &#60;style&#62; &#160;&#60;body&#62;&#60;div id=&#34;divBox&#34;&#62;&#160;&#160; &#160;&#60;p&#62;&#60;span&#62;s1&#60;/span&#62;&#60;/p&#62;&#160;&#160; &#160;&#60;p&#62;&#60;span&#62;s2&#60;/span&#62;&#60;/p&#62;&#160;&#160; &#160;&#60;p&#62;&#60;span&#62;s3&#60;/span&#62;&#60;/p&#62;&#160;&#160; &#160;&#60;p&#62;&#60;span class=&#8217;red&#8216;&#62;s4&#60;/span&#62;&#60;/p&#62;&#60;/div&#62;&#60;/body&#62; 如果按从左到右查找，哪会先查找到很多不相关的p和span元素。而如果按从右到左的方式进行查找，则首先就查找到[span class='red']的元素。firefox称这种查找方式为key selector(关键字查询)，所谓的关键字就是样式规则中最后(最右边)的规则，上面的key就是span.red。 简洁、高效的CSS: 所谓高效的CSS就是让浏览器在查找style匹配的元素的时候尽量进行少的查找，下面列出一些我们常见的写CSS犯一些低效错误(也是我以前常常犯的错误，还老以为这样写才是高效的)： 1.不要在ID选择器前使用标签名 一般写法：DIV#divBox 更好写法：#divBox 解释： 因为ID选择器是唯一的，加上div反而增加不必要的匹配。 2.不要再class选择器前使用标签名 一般写法：span.red 更好写法：.red 解释： 同第一条，但如果你定义了多个.red，而且在不同的元素下是样式不一样，则不能去掉，比如你css文件中定义如下： p.red{color:red;} span.red{color:#ff00ff} 如果是这样定义的就不要去掉，去掉后就会混淆，不过建议最好不要这样写 3.尽量少使用层级关系 一般写法：#divBox p .red{color:red;} 更好写法：.red{..} 4.使用class代替层级关系 一般写法：#divBox ul li a{display:block;} 更好写法：.block{display:block;} [...]]]></description>
			<content:encoded><![CDATA[<p>用了这么多年的CSS，现在才明白CSS的真正匹配原理，不知道你是否也跟我一样？<br />
先来看一个简单的CSS：</p>
<p><span>DIV#divBox p span.red{color:red;}，</span>按习惯我们对这个CSS 的理解是，浏览器先查找id为divBox的DIV元素，当找到后，再找其下的所有p元素，然后再查找所有span元素，当发现有span的class为red的时候，就应用该style。多么简单易懂的原理，可是这个理解却是完完全全相反、错误的。<br />
<span id="more-1340"></span><br />
<strong>匹配原理： </strong></p>
<p>浏览器CSS匹配不是从左到右进行查找，而是从右到左进行查找。比如之前说的<span>DIV#divBox p span.red{color:red;}， </span>浏览器的查找顺序如下：<br />
先查找html中所有<span>class=&#8217;red&#8217;</span>的span元素，找到后，再查找其父辈元素中是否有p元素，再判断p的父元素中是否有id为divBox的div元素，如果都存在则匹配上。<br />
浏览器从右到左进行查找的好处是为了尽早过滤掉一些无关的样式规则和元素。比如如下html和css: </p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">style</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">text/css</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"> <br />DIV#divBox p span.red{color:red;} <br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">style</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"> <br />&nbsp;<br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">body</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">divBox</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">p</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">span</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">s1</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">span</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">p</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">p</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">span</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">s2</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">span</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">p</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">p</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">span</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">s3</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">span</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">p</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">p</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">span</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=&#8217;</span><span style="color: #00008b;">red</span><span style="color: Gray;">&#8216;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">s4</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">span</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">p</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">body</span><span style="color: Olive;">&gt;</span></div>
</div>
<p>如果按从左到右查找，哪会先查找到很多不相关的p和span元素。而如果按从右到左的方式进行查找，则首先就查找到[span class='red']的元素。firefox称这种查找方式为key selector(关键字查询)，所谓的关键字就是样式规则中最后(最右边)的规则，上面的key就是span.red。 </p>
<p><strong>简洁、高效的CSS: </strong><br />
所谓高效的CSS就是让浏览器在查找style匹配的元素的时候尽量进行少的查找，下面列出一些我们常见的写CSS犯一些低效错误(也是我以前常常犯的错误，还老以为这样写才是高效的)： </p>
<p><strong>1.不要在ID选择器前使用标签名 </strong><br />
一般写法：<span>DIV#divBox </span><br />
更好写法：<span>#divBox </span><br />
解释： 因为ID选择器是唯一的，加上div反而增加不必要的匹配。 </p>
<p><strong>2.不要再class选择器前使用标签名 </strong><br />
一般写法：<span>span.red </span><br />
更好写法：<span>.red </span><br />
解释： 同第一条，但如果你定义了多个.red，而且在不同的元素下是样式不一样，则不能去掉，比如你css文件中定义如下：<br />
<span>p.red{color:red;} </span><br />
<span>span.red{color:#ff00ff} </span><br />
如果是这样定义的就不要去掉，去掉后就会混淆，不过建议最好不要这样写 </p>
<p><strong>3.尽量少使用层级关系 </strong><br />
一般写法：<span>#divBox p .red{color:red;} </span><br />
更好写法：<span>.red{..} </span></p>
<p><strong>4.使用class代替层级关系</strong><br />
一般写法：<span>#divBox ul li a{display:block;} </span><br />
更好写法：<span>.block{display:block;} </span></p>
<p>PS：看有些同学对从右到左的理论保持怀疑，下面贴出firefox和google的2篇相关css解释的文章，供大家参考 </p>
<p>mozilla firefox：<a href="https://developer.mozilla.org/en/Writing_Efficient_CSS" target="_blank">https://developer.mozilla.org/en/Writing_Efficient_CSS </a></p>
<p>google page-speed：<a href="http://code.google.com/intl/zh-CN/speed/page-speed/docs/rendering.html" target="_blank">http://code.google.com/intl/zh-CN/speed/page-speed/docs/rendering.html</a></p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=339" title="各种html+CSS实例效果 更新为2010.7.27">各种html+CSS实例效果 更新为2010.7.27</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1333" title="CSS清除浮动">CSS清除浮动</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1133" title="腾讯Q组内部考核题">腾讯Q组内部考核题</a> (12)</li><li><a href="http://www.hemin.cn/blog/?p=1068" title="我推荐的书籍">我推荐的书籍</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1037" title="CSS框架">CSS框架</a> (5)</li><li><a href="http://www.hemin.cn/blog/?p=761" title="五种实现等高方法">五种实现等高方法</a> (10)</li><li><a href="http://www.hemin.cn/blog/?p=544" title="CSS Sprites图片合并">CSS Sprites图片合并</a> (4)</li><li><a href="http://www.hemin.cn/blog/?p=527" title="CSS Reset">CSS Reset</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=472" title="css长度单位">css长度单位</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=270" title="CSS居中问题">CSS居中问题</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1340</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS清除浮动</title>
		<link>http://www.hemin.cn/blog/?p=1333</link>
		<comments>http://www.hemin.cn/blog/?p=1333#comments</comments>
		<pubDate>Mon, 05 Jul 2010 16:43:44 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[(x)Html/Css]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[技巧]]></category>
		<category><![CDATA[清除]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1333</guid>
		<description><![CDATA[使用div+css（姑且这样叫，虽然我也不喜欢，但是叫什么呢？）布局的好处不用多说，经常性地会使用到float，那么清除浮动就是必须要做的，而且随时性地对父级元素清除浮动的做法也被认为是书写CSS的良好习惯之一。 常用的清除浮动的方法有以下三种。 此为未清除浮动源代码，运行代码无法查看到父级元素浅黄色背景。 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62; &#60;title&#62;未清除浮动&#60;/title&#62; &#60;style type=&#34;text/css&#34;&#62; *{margin:0;padding:0;} body{font:36px bold; color:#F00; text-align:center;} #layout{background:#FF9;} #left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;} #right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;} &#60;/style&#62; &#60;/head&#62; &#60;body&#62; &#60;div id=&#34;layout&#34;&#62; &#60;div id=&#34;left&#34;&#62;Left&#60;/div&#62; &#60;div id=&#34;right&#34;&#62;Right&#60;/div&#62; &#60;/div&#62; &#60;/body&#62; &#60;/html&#62; 提示：你可以先修改部分代码再运行。 1、使用空标签清除浮动。某些同学用了很久的一种方法，空标签可以是div标签，也可以是P标签。我习惯用P，够简短，也有很多人用hr，只是需要另外为其清除边框，但理论上可以是任何标签。这种方式是在需要清除浮动的父级元素内部的所有浮动元素后添加这样一个标签清楚浮动，并为其定义CSS代码：clear:both。此方法的弊端在于增加了无意义的结构元素。 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>使用div+css（姑且这样叫，虽然我也不喜欢，但是叫什么呢？）布局的好处不用多说，经常性地会使用到float，那么清除浮动就是必须要做的，而且随时性地对父级元素清除浮动的做法也被认为是书写CSS的良好习惯之一。</p>
<p>常用的清除浮动的方法有以下三种。<br />
此为未清除浮动源代码，运行代码无法查看到父级元素浅黄色背景。 </p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_Z6yzrY"> &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;未清除浮动&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{margin:0;padding:0;}
body{font:36px bold; color:#F00; text-align:center;}
#layout{background:#FF9;}
#left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
#right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;layout&quot;&gt;
    &lt;div id=&quot;left&quot;&gt;Left&lt;/div&gt;
    &lt;div id=&quot;right&quot;&gt;Right&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_Z6yzrY');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_Z6yzrY');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_Z6yzrY','runcode_Z6yzrY');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><span id="more-1333"></span><br />
<strong>1、使用空标签清除浮动。</strong>某些同学用了很久的一种方法，空标签可以是div标签，也可以是P标签。我习惯用P，够简短，也有很多人用hr，只是需要另外为其清除边框，但理论上可以是任何标签。这种方式是在需要清除浮动的父级元素内部的所有浮动元素后添加这样一个标签清楚浮动，并为其定义CSS代码：clear:both。此方法的弊端在于增加了无意义的结构元素。</p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_V5jPee">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;空标签清除浮动&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{margin:0;padding:0;}
body{font:36px bold; color:#F00; text-align:center;}
#layout{background:#FF9;}
#left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
#right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
.clear{clear:both;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;layout&quot;&gt;
    &lt;div id=&quot;left&quot;&gt;Left&lt;/div&gt;
    &lt;div id=&quot;right&quot;&gt;Right&lt;/div&gt;
    &lt;div class=&quot;clear&quot;&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_V5jPee');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_V5jPee');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_V5jPee','runcode_V5jPee');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>2、使用overflow属性。</strong>此方法有效地解决了通过空标签元素清除浮动而不得不增加无意代码的弊端。使用该方法是只需在需要清除浮动的元素中定义CSS属性：overflow:hidden，即可！&#8221;zoom:1&#8243;用于兼容IE6。</p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_pa2UtI">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;overflow清除浮动&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{margin:0;padding:0;}
body{font:36px bold; color:#F00; text-align:center;}
#layout{background:#FF9;overflow:hidden;_zoom:1;}
#left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
#right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;layout&quot;&gt;
    &lt;div id=&quot;left&quot;&gt;Left&lt;/div&gt;
    &lt;div id=&quot;right&quot;&gt;Right&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_pa2UtI');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_pa2UtI');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_pa2UtI','runcode_pa2UtI');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p><strong>3、使用after伪对象清除浮动。</strong>该方法因为要写好几个属性,不到特殊情况，不推荐使用。具体写法可参照以下示例。使用中需注意以下几点。一、该方法中必须为需要清除浮动元素的伪对象中设置height:0，否则该元素会比实际高出若干像素；二、content属性是必须的，但其值可以为空，蓝色理想讨论该方法的时候 content属性的值设为&#8221;.&#8221;，但我发现为空亦是可以的。</p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_oCjkJm">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;after伪对象清除浮动&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{margin:0;padding:0;}
body{font:36px bold; color:#F00; text-align:center;}
#layout{background:#FF9;}
#layout:after{display:block;clear:both;content:&quot;&quot;;visibility:hidden;height:0;}
#left{float:left;width:20%;height:200px;background:#DDD;line-height:200px;}
#right{float:right;width:30%;height:80px;background:#DDD;line-height:80px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;layout&quot;&gt;
    &lt;div id=&quot;left&quot;&gt;Left&lt;/div&gt;
    &lt;div id=&quot;right&quot;&gt;Right&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_oCjkJm');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_oCjkJm');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_oCjkJm','runcode_oCjkJm');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=761" title="五种实现等高方法">五种实现等高方法</a> (10)</li><li><a href="http://www.hemin.cn/blog/?p=544" title="CSS Sprites图片合并">CSS Sprites图片合并</a> (4)</li><li><a href="http://www.hemin.cn/blog/?p=527" title="CSS Reset">CSS Reset</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=270" title="CSS居中问题">CSS居中问题</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=44" title="各种浏览器css hack  更新为2009.8.7">各种浏览器css hack  更新为2009.8.7</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=339" title="各种html+CSS实例效果 更新为2010.7.27">各种html+CSS实例效果 更新为2010.7.27</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1340" title="CSS查找匹配原理和简洁高效">CSS查找匹配原理和简洁高效</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1286" title="各种jQuery技巧">各种jQuery技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1133" title="腾讯Q组内部考核题">腾讯Q组内部考核题</a> (12)</li><li><a href="http://www.hemin.cn/blog/?p=1068" title="我推荐的书籍">我推荐的书籍</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1333</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery性能优化</title>
		<link>http://www.hemin.cn/blog/?p=1313</link>
		<comments>http://www.hemin.cn/blog/?p=1313#comments</comments>
		<pubDate>Sun, 04 Jul 2010 18:06:40 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[JS/JQuery]]></category>
		<category><![CDATA[JQ]]></category>
		<category><![CDATA[优化]]></category>
		<category><![CDATA[性能]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1313</guid>
		<description><![CDATA[现在越来越多的人应用jQuery了，有些同学在享受爽快淋漓coding时就将性能问题忽略了, 比如我. jquery虽在诸多的js类库中性能表现还算优秀, 但毕竟不是在用原生的javascript开发, 性能问题还是需要引起重视的. 总是从ID选择器开始继承 在class前使用tag 将jquery对象缓存起来 掌握强大的链式操作 使用子查询 对直接的DOM操作进行限制 冒泡 消除无效查询 推迟到 $(window).load 压缩js 全面掌握jquery库 1. 总是从ID选择器开始继承 在jquery中最快的选择器是ID选择器. 因为它直接来自于Javascript的getElementById()方法. &#60;div id=&#34;content&#34;&#62;&#160;&#160; &#160;&#60;form method=&#34;post&#34; action=&#34;/&#34;&#62;&#160;&#160; &#160; &#160; &#160;&#60;h2&#62;Traffic Light&#60;/h2&#62;&#160;&#160; &#160; &#160; &#160;&#60;ul id=&#34;traffic_light&#34;&#62;&#160;&#160; &#160; &#160; &#160; &#160; &#160;&#60;li&#62;&#60;input type=&#34;radio&#34; class=&#34;on&#34; name=&#34;light&#34; value=&#34;red&#34; /&#62; Red&#60;/li&#62;&#160;&#160; &#160; &#160; &#160; &#160; &#160;&#60;li&#62;&#60;input type=&#34;radio&#34; class=&#34;off&#34; name=&#34;light&#34; value=&#34;yellow&#34; /&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>现在越来越多的人应用jQuery了，有些同学在享受爽快淋漓coding时就将性能问题忽略了,  比如我.  jquery虽在诸多的js类库中性能表现还算优秀, 但毕竟不是在用原生的javascript开发, 性能问题还是需要引起重视的. </p>
<ol style="font-size:14px">
<li><a href="#descend-from-an-#id">总是从ID选择器开始继承</a></li>
<li><a href="#use-tags-before-classes">在class前使用tag</a></li>
<li><a href="#cache-jquery-objects">将jquery对象缓存起来</a></li>
<li><a href="#harness-the-power-of-chaining">掌握强大的链式操作</a></li>
<li><a href="#use-sub-queries">使用子查询</a></li>
<li><a href="#limit-direct-dom-manipulation">对直接的DOM操作进行限制</a></li>
<li><a href="#leverage-event-delegation">冒泡</a></li>
<li><a href="#eliminate-query-waste">消除无效查询</a></li>
<li><a href="#defer-to-window-load">推迟到 $(window).load</a></li>
<li><a href="#compress-your-js">压缩js</a></li>
<li><a href="#learn-the-library">全面掌握jquery库</a></li>
</ol>
<p><span id="more-1313"></span></p>
<h3 id="descend-from-an-#id">1. 总是从ID选择器开始继承</h3>
<p>在jquery中最快的选择器是ID选择器. 因为它直接来自于Javascript的getElementById()方法.</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">content</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">form</span><span style="color: Gray;"> </span><span style="color: #00008b;">method</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">post</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">action</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">/</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">h2</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">Traffic Light</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">h2</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">ul</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">traffic_light</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">on</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">red</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Red</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">off</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">yellow</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Yellow</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">off</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">green</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Green</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">ul</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">button</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">traffic_button</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">submit</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Go</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">form</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span></div>
</div>
<p>像这样选择按钮是低效的:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">traffic_button</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#content .button</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>用ID直接选择按钮效率更高:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">traffic_button</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">traffic_button</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>选择多个元素</p>
<p>提到多元素选择其实是在说DOM遍历和循环, 这些都是比较慢的东西.为了提高性能, 最好从就近的ID开始继承.</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">traffic_lights</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> </span><span style="color: Blue;">input</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<h3 id="use-tags-before-classes">2. 在class前使用tag</h3>
<p>第二快的选择器是tag选择器($(‘head’)). 同理,因为它来自原生的getElementsByTagName() 方法.</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">content</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">form</span><span style="color: Gray;"> </span><span style="color: #00008b;">method</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">post</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">action</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">/</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">h2</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">Traffic Light</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">h2</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">ul</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">traffic_light</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">on</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">red</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Red</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">off</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">yellow</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Yellow</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">off</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">green</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Green</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">ul</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">button</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">traffic_button</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">submit</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Go</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">form</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span></div>
</div>
<p>总是用一个tag name来限制(修饰)class (并且不要忘记就近的ID):</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">active_light</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> </span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">on</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>注意: 在jquery中Class是最慢的选择器. IE浏览器下它会遍历所有DOM节点不管它用在那里.</p>
<p>不要用用tag name来修饰ID. 下面的例子将会遍历所有的div元素来查找id为’content’的哪一个节点:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">content</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">div</span><span style="color: Gray;">#</span><span style="color: Blue;">content</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>用ID修饰ID也是画蛇添足:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">content</span><span style="color: Gray;"> #</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<h3 id="cache-jquery-objects">3. 将jquery对象缓存起来</h3>
<p>要养成将jquery对象缓存进变量的习惯.</p>
<p>永远不要这样做:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> </span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">on</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">bind</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">click</span><span style="color: Gray;">‘, </span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;">…</span><span style="color: Olive;">})</span><span style="color: Gray;">;<br />$</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> </span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">on</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">border</span><span style="color: Gray;">’, ’</span><span style="color: Maroon;">3</span><span style="color: Blue;">px</span><span style="color: Gray;"> </span><span style="color: Blue;">dashed</span><span style="color: Gray;"> </span><span style="color: Blue;">yellow</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />$</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> </span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">on</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">background</span><span style="color: Gray;">-</span><span style="color: Blue;">color</span><span style="color: Gray;">‘, ‘</span><span style="color: Blue;">orange</span><span style="color: Gray;">‘</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />$</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> </span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">on</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">fadeIn</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">slow</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>最好先将对象缓存进一个变量然后再操作:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> $</span><span style="color: Blue;">active_light</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> </span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">on</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />$</span><span style="color: Blue;">active_light</span><span style="color: Gray;">.</span><span style="color: Blue;">bind</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">click</span><span style="color: Gray;">’, </span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;">…</span><span style="color: Olive;">})</span><span style="color: Gray;">;<br />$</span><span style="color: Blue;">active_light</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">border</span><span style="color: Gray;">’, ’</span><span style="color: Maroon;">3</span><span style="color: Blue;">px</span><span style="color: Gray;"> </span><span style="color: Blue;">dashed</span><span style="color: Gray;"> </span><span style="color: Blue;">yellow</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />$</span><span style="color: Blue;">active_light</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">background</span><span style="color: Gray;">-</span><span style="color: Blue;">color</span><span style="color: Gray;">’, ‘</span><span style="color: Blue;">orange</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />$</span><span style="color: Blue;">active_light</span><span style="color: Gray;">.</span><span style="color: Blue;">fadeIn</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">slow</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>为了记住我们本地变量是jquery的封装, 通常用一个$作为变量前缀. 记住,永远不要让相同的选择器在你的代码里出现多次.<br />
缓存jquery结果,备用</p>
<p>如果你打算将jquery结果对象用在程序的其它部分,或者你的function会多次执行, 那么就将他们缓存到一个全局变量中.</p>
<p>定义一个全局容器来存放jquery结果, 我们就可以在其它函数引用它们:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: #ffa500;">// 在全局范围定义一个对象 (例如: window对象)</span><span style="color: Gray;"><br /></span><span style="color: Teal;">window</span><span style="color: Gray;">.$</span><span style="color: Blue;">my</span><span style="color: Gray;"> =<br /></span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// 初始化所有可能会不止一次要使用的查询</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">head</span><span style="color: Gray;"> : $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">head</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">,<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> : $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#traffic_light</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">,<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">traffic_button</span><span style="color: Gray;"> : $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#traffic_button</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;"><br /></span><span style="color: Olive;">}</span><span style="color: Gray;">;<br />&nbsp;<br /></span><span style="color: Green;">function</span><span style="color: Gray;"> </span><span style="color: Blue;">do_something</span><span style="color: Olive;">()</span><span style="color: Gray;"><br /></span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">//现在你可以引用存储的结果并操作它们</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">script</span><span style="color: Gray;"> = </span><span style="color: Teal;">document</span><span style="color: Gray;">.</span><span style="color: Blue;">createElement</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">script</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Blue;">my</span><span style="color: Gray;">.</span><span style="color: Blue;">head</span><span style="color: Gray;">.</span><span style="color: Blue;">append</span><span style="color: Olive;">(</span><span style="color: Blue;">script</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// 当你在函数内部操作是, 可以继续将查询存入全局对象中去.</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Blue;">my</span><span style="color: Gray;">.</span><span style="color: Blue;">cool_results</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#some_ul li</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Blue;">my</span><span style="color: Gray;">.</span><span style="color: Blue;">other_results</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#some_table td</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// 将全局函数作为一个普通的jquery对象去使用.</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Blue;">my</span><span style="color: Gray;">.</span><span style="color: Blue;">other_results</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">border-color</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">red</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Blue;">my</span><span style="color: Gray;">.</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">border-color</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">green</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br /></span><span style="color: Olive;">}</span></div>
</div>
<h3 id="harness-the-power-of-chaining">4. 掌握强大的链式操作</h3>
<p>上面的例子也可以写成这样:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> $</span><span style="color: Blue;">active_light</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> </span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">on</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;$</span><span style="color: Blue;">active_light</span><span style="color: Gray;">.</span><span style="color: Blue;">bind</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">click</span><span style="color: Gray;">’, </span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;">…</span><span style="color: Olive;">})</span><span style="color: Gray;"><br />.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">border</span><span style="color: Gray;">’, ’</span><span style="color: Maroon;">3</span><span style="color: Blue;">px</span><span style="color: Gray;"> </span><span style="color: Blue;">dashed</span><span style="color: Gray;"> </span><span style="color: Blue;">yellow</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;"><br />.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">background</span><span style="color: Gray;">-</span><span style="color: Blue;">color</span><span style="color: Gray;">’, ‘</span><span style="color: Blue;">orange</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;"><br />.</span><span style="color: Blue;">fadeIn</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">slow</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>这样可以写更少的代码, 让我们的js更轻量.</p>
<h3 id="use-sub-queries">5. 使用子查询</h3>
<p>jQuery 允许我们对一个已包装的对象使用附加的选择器操作. 因为我们已经在保存了一个父级对象在变量里, 这样大大提高对其子元素的操作:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">content</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">form</span><span style="color: Gray;"> </span><span style="color: #00008b;">method</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">post</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">action</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">/</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">h2</span><span style="color: Olive;">&gt;</span><span style="color: Gray;">Traffic Light</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">h2</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">ul</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">traffic_light</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">on</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">red</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Red</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">off</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">yellow</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Yellow</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">off</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">green</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Green</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">ul</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">button</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">traffic_button</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">submit</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Go</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">form</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span></div>
</div>
<p>例如, 我们可以用子查询的方法来抓取到亮或不亮的灯, 并缓存起来以备后续操作.</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> $</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Gray;">‘#</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">,<br />$</span><span style="color: Blue;">active_light</span><span style="color: Gray;"> = $</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;">.</span><span style="color: Blue;">find</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">on</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">,<br />$</span><span style="color: Blue;">inactive_lights</span><span style="color: Gray;"> = $</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;">.</span><span style="color: Blue;">find</span><span style="color: Olive;">(</span><span style="color: Gray;">‘</span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">off</span><span style="color: Gray;">’</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>提示: 你可以用逗号分隔的方法一次声明多个局部变量–节省字节数</p>
<h3 id="limit-direct-dom-manipulation">6. 对直接的DOM操作进行限制</h3>
<p>这里的基本思想是在内存中建立你确实想要的东西，然后更新DOM 。这并不是一个jQuery最佳实践，但必须进行有效的JavaScript操作 。直接的DOM操作速度很慢。</p>
<p>例如,你想动态的创建一组列表元素, 千万不要这么做:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">top_100_list</span><span style="color: Gray;"> = </span><span style="color: Olive;">[</span><span style="color: Gray;">...</span><span style="color: Olive;">]</span><span style="color: Gray;">, </span><span style="color: #ffa500;">//假设这里是100个独一无二的字符串</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Blue;">mylist</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#mylist</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: #ffa500;">//jQuery 选择到 &lt;ul&gt; 元素t</span><span style="color: Gray;"><br />&nbsp;<br /></span><span style="color: Green;">for</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">i</span><span style="color: Gray;">=</span><span style="color: Maroon;">0</span><span style="color: Gray;">, </span><span style="color: Blue;">l</span><span style="color: Gray;">=</span><span style="color: Blue;">top_100_list</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Gray;">; </span><span style="color: Blue;">i</span><span style="color: Gray;">&lt;</span><span style="color: Blue;">l</span><span style="color: Gray;">; </span><span style="color: Blue;">i</span><span style="color: Gray;">++</span><span style="color: Olive;">)</span><span style="color: Gray;"><br /></span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Blue;">mylist</span><span style="color: Gray;">.</span><span style="color: Blue;">append</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">&lt;li&gt;</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;"> + </span><span style="color: Blue;">top_100_list</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;"> + </span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">&lt;/li&gt;</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br /></span><span style="color: Olive;">}</span></div>
</div>
<p>我们应该将整套元素字符串在插入进dom中之前全部创建好:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">top_100_list</span><span style="color: Gray;"> = </span><span style="color: Olive;">[</span><span style="color: Gray;">...</span><span style="color: Olive;">]</span><span style="color: Gray;">, </span><span style="color: #ffa500;">// assume this has 100 unique strings</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Blue;">mylist</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#mylist</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">, </span><span style="color: #ffa500;">// jQuery selects our &lt;ul&gt; element</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">top_100_li</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;&quot;</span><span style="color: Gray;">; </span><span style="color: #ffa500;">// 这个变量将用来存储我们的列表元素</span><span style="color: Gray;"><br />&nbsp;<br /></span><span style="color: Green;">for</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">i</span><span style="color: Gray;">=</span><span style="color: Maroon;">0</span><span style="color: Gray;">, </span><span style="color: Blue;">l</span><span style="color: Gray;">=</span><span style="color: Blue;">top_100_list</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Gray;">; </span><span style="color: Blue;">i</span><span style="color: Gray;">&lt;</span><span style="color: Blue;">l</span><span style="color: Gray;">; </span><span style="color: Blue;">i</span><span style="color: Gray;">++</span><span style="color: Olive;">)</span><span style="color: Gray;"><br /></span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">top_100_li</span><span style="color: Gray;"> += </span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">&lt;li&gt;</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;"> + </span><span style="color: Blue;">top_100_list</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;"> + </span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">&lt;/li&gt;</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">;<br /></span><span style="color: Olive;">}</span><span style="color: Gray;"><br />$</span><span style="color: Blue;">mylist</span><span style="color: Gray;">.</span><span style="color: Blue;">html</span><span style="color: Olive;">(</span><span style="color: Blue;">top_100_li</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>我们在插入之前将多个元素包裹进一个单独的父级节点会更快:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">top_100_list</span><span style="color: Gray;"> = </span><span style="color: Olive;">[</span><span style="color: Gray;">...</span><span style="color: Olive;">]</span><span style="color: Gray;">, </span><span style="color: #ffa500;">// assume this has 100 unique strings</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Blue;">mylist</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#mylist</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">, </span><span style="color: #ffa500;">// jQuery selects our &lt;ul&gt; element</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">top_100_ul</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">&lt;ul id=&quot;#mylist&quot;&gt;</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">; </span><span style="color: #ffa500;">// This will store our entire unordered list</span><span style="color: Gray;"><br />&nbsp;<br /></span><span style="color: Green;">for</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">i</span><span style="color: Gray;">=</span><span style="color: Maroon;">0</span><span style="color: Gray;">, </span><span style="color: Blue;">l</span><span style="color: Gray;">=</span><span style="color: Blue;">top_100_list</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Gray;">; </span><span style="color: Blue;">i</span><span style="color: Gray;">&lt;</span><span style="color: Blue;">l</span><span style="color: Gray;">; </span><span style="color: Blue;">i</span><span style="color: Gray;">++</span><span style="color: Olive;">)</span><span style="color: Gray;"><br /></span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">top_100_ul</span><span style="color: Gray;"> += </span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">&lt;li&gt;</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;"> + </span><span style="color: Blue;">top_100_list</span><span style="color: Olive;">[</span><span style="color: Blue;">i</span><span style="color: Olive;">]</span><span style="color: Gray;"> + </span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">&lt;/li&gt;</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">;<br /></span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Blue;">top_100_ul</span><span style="color: Gray;"> += </span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">&lt;/ul&gt;</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">; </span><span style="color: #ffa500;">// //关闭无序列表</span><span style="color: Gray;"><br />&nbsp;<br />$</span><span style="color: Blue;">mylist</span><span style="color: Gray;">.</span><span style="color: Blue;">replaceWith</span><span style="color: Olive;">(</span><span style="color: Blue;">top_100_ul</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></div>
</div>
<p>如果你做了以上几条还是担心有性能问题,那么:</p>
<ul>
<li>试试jquery的 clone() 方法, 它会创建一个节点树的副本, 它允许以”离线”的方式进行dom操作, 当你操作完成后再将其放回到节点树里.</li>
<li>使用<a href="http://www.devguru.com/technologies/xmldom/quickref/obj_documentFragment.html" target="_blank">DOM DocumentFragments</a>. 正如jQuery作者所言, 它的性能要明显优于直接的dom操作.</li>
</ul>
<h3 id="leverage-event-delegation">7. 冒泡</h3>
<p>除非在特殊情况下, 否则每一个js事件(例如:click, mouseover, 等.)都会冒泡到父级节点. 当我们需要给多个元素调用同个函数时这点会很有用.</p>
<p>代替这种效率很差的多元素事件监听的方法就是, 你只需向它们的父节点绑定一次, 并且可以计算出哪个节点触发了事件.</p>
<p>例如, 我们要为一个拥有很多输入框的表单绑定这样的行为: 当输入框被选中时为它添加一个class</p>
<p>像这样绑定事件是低效的:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#entryform input).bind(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Blue;">focus</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">, function(){<br />&nbsp;&nbsp; &nbsp;$(this).addClass(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Blue;">selected</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">);<br />&nbsp;&nbsp; &nbsp;}).bind(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Blue;">blur</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">, function(){<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$(this).removeClass(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Blue;">selected</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">);<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;});</span></div>
</div>
<p>我们需要在父级监听获取焦点和失去焦点的事件:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#entryform</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">bind</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">focus</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">, </span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">e</span><span style="color: Olive;">){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">cell</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Blue;">e</span><span style="color: Gray;">.</span><span style="color: Blue;">target</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: #ffa500;">// e.target grabs the node that triggered the event.</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">cell</span><span style="color: Gray;">.</span><span style="color: Blue;">addClass</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">selected</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">.</span><span style="color: Blue;">bind</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">blur</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">, </span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">e</span><span style="color: Olive;">){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">cell</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Blue;">e</span><span style="color: Gray;">.</span><span style="color: Blue;">target</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">cell</span><span style="color: Gray;">.</span><span style="color: Blue;">removeClass</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">selected</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p>父级元素扮演了一个调度员的角色, 它可以基于目标元素绑定事件. 如果你发现你给很多元素绑定了同一个事件监听, 那么你肯定哪里做错了.</p>
<h3 id="eliminate-query-waste">8. 消除无效查询</h3>
<p>尽管jquery可以很优雅的处理没有匹配元素的情况, 但它还是需要花费时间去寻找. 如果你整站只有一个全局js, 那么极有可能把所有的jquery函数塞进$(document)ready(function(){//所有你引以为傲的代码})里.</p>
<p>只运行在页面里用到的函数. 大多数有效的方法就是使用行内初始化函数, 这样你的模板就能准确的控制何时何处该执行js.</p>
<p>例如, 你的”文章”页面模板, 你可能会引用如下的代码在body结束处:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">script</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">text/javascript&gt;<br />mylib.article.init();<br />&lt;/script&gt;<br />&lt;/body&gt;</span></div>
</div>
<p>如果你的页面模板包含一些多变的模块可能不会出现在页面中, 或者为了视觉呈现的原因你需要它们能够快速加载, 你可以将初始化函数紧跟在模块之后.</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">ul</span><span style="color: Gray;"> </span><span style="color: #00008b;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">traffic_light</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">on</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">red</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Red</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">off</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">yellow</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Yellow</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">&lt;</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;&lt;</span><span style="color: Green;">input</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">radio</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">off</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">light</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">value</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">green</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">/&gt;</span><span style="color: Gray;"> Green</span><span style="color: Olive;">&lt;/</span><span style="color: Green;">li</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;/</span><span style="color: Green;">ul</span><span style="color: Olive;">&gt;</span><span style="color: Gray;"><br /></span><span style="color: Olive;">&lt;</span><span style="color: Green;">script</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">text/javascript&gt;<br />mylib.traffic_light.init();<br />&lt;/script&gt;</span></div>
</div>
<p>你的全局js库可能会是这样子的:</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">mylib</span><span style="color: Gray;"> =<br /></span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">article_page</span><span style="color: Gray;"> :<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">init</span><span style="color: Gray;"> : </span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">// Article page specific jQuery functions.</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">,<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">traffic_light</span><span style="color: Gray;"> :<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">init</span><span style="color: Gray;"> : </span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">// Traffic light specific jQuery functions.</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Olive;">}</span></div>
</div>
<h3 id="defer-to-window-load">9. 推迟到 $(window).load</h3>
<p>jquery对于开发者来说有一个很诱人的东西, 可以把任何东西挂到$(document).ready下冒充事件. 在大多数例子中你都会发现这样的情况.</p>
<p>尽管$(document).rady 确实很有用, 它可以在页面渲染时,其它元素还没下载完成就执行. 如果你发现你的页面一直是载入中的状态, 很有可能就是$(document).ready函数引起的.</p>
<p>你可以通过将jquery函数绑定到$(window).load 事件的方法来减少页面载入时的cpu使用率. 它会在所有的html(包括iframe)被下载完成后执行.</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Teal;">window</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">load</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;"><br /></span><span style="color: #ffa500;">// 页面完全载入后才初始化的jQuery函数.</span><span style="color: Gray;"><br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p>多余的功能例如拖放, 视觉特效和动画, 预载入隐藏图像,等等. 都是适合这种技术的场合.</p>
<h3 id="compress-your-js">10. 压缩js</h3>
<p>推荐一个js在线压缩地址: <a href="http://dean.edwards.name/packer/" target="_blank">http://dean.edwards.name/packer/</a></p>
<h3 id="learn-the-library">11. 全面掌握jquery库</h3>
<p>知己知彼, 百战百胜.  只有更深入的了解jQuery才能更灵活的使用它.  这里提供一个<a href="http://www.artzstudio.com/files/jquery-rules/jquery_1.3_cheatsheet_v1.pdf" target="_blank">jQuery的速查手册</a>, 可以打印出来随身携带.  要是有能力将jQuery源码通读一遍那就更好了.</p>
<p>原文：<a href="http://www.artzstudio.com/2009/04/jquery-performance-rules/#use-tags-before-classes" target="_blank">http://www.artzstudio.com/2009/04/jquery-performance-rules/#use-tags-before-classes</a></p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=1354" title="tudou首页图片延迟加载">tudou首页图片延迟加载</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1270" title="各种jquery实例效果">各种jquery实例效果</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1286" title="各种jQuery技巧">各种jQuery技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1167" title="40条优化php代码的小实例">40条优化php代码的小实例</a> (2)</li><li><a href="http://www.hemin.cn/blog/?p=1068" title="我推荐的书籍">我推荐的书籍</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1022" title="各种jQuery插件">各种jQuery插件</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=984" title="JQ模块库09.12.08">JQ模块库09.12.08</a> (35)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1313</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>各种jQuery技巧</title>
		<link>http://www.hemin.cn/blog/?p=1286</link>
		<comments>http://www.hemin.cn/blog/?p=1286#comments</comments>
		<pubDate>Sun, 04 Jul 2010 14:37:31 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[JS/JQuery]]></category>
		<category><![CDATA[JQ]]></category>
		<category><![CDATA[技巧]]></category>
		<category><![CDATA[收藏]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1286</guid>
		<description><![CDATA[收集和原创各种jQuery技巧。（为了工作需要和学习得更多） &#60;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&#34;&#62;&#60;/script&#62; 1、 去除页面的右键菜单 $(function(){&#160; &#160;&#160; &#160;$(document).bind(&#34;contextmenu&#34;,function(e){&#160; &#160;&#160; &#160; &#160; &#160;return false;&#160; &#160;&#160; &#160;});&#160; }); 2、搜索输入框文字的消失 当鼠标获得焦点、失去焦点的时候，input输入框文字处理： $(function(){&#160;&#160; &#160;$(&#34;input.text1&#34;).val(&#34;Enter your search text here&#34;);&#160;&#160; &#160;textFill($(&#8216;input.text1&#8216;));});function textFill(input){ //input focus text function &#160;&#160; &#160;var originalvalue = input.val();&#160; &#160;&#160; &#160;input.focus( function(){&#160; &#160;&#160; &#160; &#160; &#160;if( $.trim(input.val()) == originalvalue ){ input.val(&#8221;); }&#160; &#160;&#160; &#160;});&#160; &#160;&#160; &#160;input.blur( function(){&#160; &#160;&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>收集和原创各种jQuery技巧。（为了工作需要和学习得更多）</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Olive;">&lt;</span><span style="color: Green;">script</span><span style="color: Gray;"> </span><span style="color: #00008b;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">text/javascript</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: #00008b;">src</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">&gt;&lt;/</span><span style="color: Green;">script</span><span style="color: Olive;">&gt;</span></div>
</div>
<p><strong>1、 去除页面的右键菜单</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: Teal;">document</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">bind</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">contextmenu</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">e</span><span style="color: Olive;">){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">false</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><span id="more-1286"></span><br />
<strong>2、搜索输入框文字的消失</strong><br />
当鼠标获得焦点、失去焦点的时候，input输入框文字处理：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">input.text1</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Enter your search text here</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">textFill</span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">input.text1</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">))</span><span style="color: Gray;">;<br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;<br /></span><span style="color: Green;">function</span><span style="color: Gray;"> </span><span style="color: Blue;">textFill</span><span style="color: Olive;">(</span><span style="color: Blue;">input</span><span style="color: Olive;">){</span><span style="color: Gray;"> </span><span style="color: #ffa500;">//input focus text function </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">originalvalue</span><span style="color: Gray;"> = </span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">()</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">focus</span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Gray;"> $.</span><span style="color: Blue;">trim</span><span style="color: Olive;">(</span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">())</span><span style="color: Gray;"> == </span><span style="color: Blue;">originalvalue</span><span style="color: Gray;"> </span><span style="color: Olive;">){</span><span style="color: Gray;"> </span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8221;</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">blur</span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Gray;"> $.</span><span style="color: Blue;">trim</span><span style="color: Olive;">(</span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">())</span><span style="color: Gray;"> == </span><span style="color: #8b0000;">&#8221;</span><span style="color: Gray;"> </span><span style="color: Olive;">){</span><span style="color: Gray;"> </span><span style="color: Blue;">input</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: Blue;">originalvalue</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">}</span></div>
</div>
<p><strong>3、新窗口打开页面</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; </span><span style="color: #ffa500;">//Example 1: Every link will open in a new window&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">a[href^=&quot;http://&quot;]</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">attr</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">target</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">_blank</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; </span><span style="color: #ffa500;">//Example 2: Links with the rel=&quot;external&quot; attribute will only open in a new window&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">a[@rel$=&quot;external&quot;]</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">target</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">_blank</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; </span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;<br />&nbsp;<br /></span><span style="color: #ffa500;">// how to use</span><span style="color: Gray;"><br />&lt;</span><span style="color: Blue;">a</span><span style="color: Gray;"> </span><span style="color: Blue;">href</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">http://www.opensourcehunter.com</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">rel</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">external</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&gt;</span><span style="color: Blue;">open</span><span style="color: Gray;"> </span><span style="color: Blue;">link</span><span style="color: Gray;">&lt;</span><span style="color: #8b0000;">/</span><span style="color: Red;">a&gt;</span></div>
</div>
<p><strong>4、判断浏览器类型</strong><br />
注意： jQuery 1.4中$.support 来代替以前的$.browser </p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// Target Firefox 2 and above&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;">$.</span><span style="color: Blue;">browser</span><span style="color: Gray;">.</span><span style="color: Blue;">mozilla</span><span style="color: Gray;"> &amp;&amp; $.</span><span style="color: Blue;">browser</span><span style="color: Gray;">.</span><span style="color: Blue;">version</span><span style="color: Gray;"> &gt;= </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">1.8</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">// do something&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// Target Safari&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Gray;"> $.</span><span style="color: Blue;">browser</span><span style="color: Gray;">.</span><span style="color: Blue;">safari</span><span style="color: Gray;"> </span><span style="color: Olive;">){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">// do something&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// Target Chrome&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Gray;"> $.</span><span style="color: Blue;">browser</span><span style="color: Gray;">.</span><span style="color: Blue;">chrome</span><span style="color: Olive;">){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">// do something&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// Target Camino&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Gray;"> $.</span><span style="color: Blue;">browser</span><span style="color: Gray;">.</span><span style="color: Blue;">camino</span><span style="color: Olive;">){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">// do something&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// Target Opera&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Gray;"> $.</span><span style="color: Blue;">browser</span><span style="color: Gray;">.</span><span style="color: Blue;">opera</span><span style="color: Olive;">){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">// do something&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// Target IE6 and below&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;">$.</span><span style="color: Blue;">browser</span><span style="color: Gray;">.</span><span style="color: Blue;">msie</span><span style="color: Gray;"> &amp;&amp; $.</span><span style="color: Blue;">browser</span><span style="color: Gray;">.</span><span style="color: Blue;">version</span><span style="color: Gray;"> &lt;= </span><span style="color: Maroon;">6</span><span style="color: Gray;"> </span><span style="color: Olive;">){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">// do something&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; &nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// Target anything above IE6&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;">$.</span><span style="color: Blue;">browser</span><span style="color: Gray;">.</span><span style="color: Blue;">msie</span><span style="color: Gray;"> &amp;&amp; $.</span><span style="color: Blue;">browser</span><span style="color: Gray;">.</span><span style="color: Blue;">version</span><span style="color: Gray;"> &gt; </span><span style="color: Maroon;">6</span><span style="color: Olive;">){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">// do something&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>5、轻松切换css样式</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">a.Styleswitcher</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//swicth the LINK REL attribute with the value in A REL attribute&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">link[rel=stylesheet]</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">attr</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">href</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;"> , $</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">attr</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">rel</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">))</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;<br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;<br /></span><span style="color: #ffa500;">// how to use</span><span style="color: Gray;"><br /></span><span style="color: #ffa500;">// place this in your header</span><span style="color: Gray;"><br />&lt;</span><span style="color: Blue;">link</span><span style="color: Gray;"> </span><span style="color: Blue;">rel</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">stylesheet</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">href</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">default.css</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">type</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">text/css</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&gt;&nbsp; <br /></span><span style="color: #ffa500;">// the links&nbsp; </span><span style="color: Gray;"><br />&lt;</span><span style="color: Blue;">a</span><span style="color: Gray;"> </span><span style="color: Blue;">href</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Green;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Styleswitcher</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">rel</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">default.css</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&gt;</span><span style="color: Blue;">Default</span><span style="color: Gray;"> </span><span style="color: Blue;">Theme</span><span style="color: Gray;">&lt;</span><span style="color: #8b0000;">/</span><span style="color: Red;">a&gt;&nbsp; <br />&lt;a href=&quot;#&quot; class=&quot;Styleswitcher&quot; rel=&quot;red.css&quot;&gt;Red Theme&lt;</span><span style="color: #8b0000;">/</span><span style="color: Blue;">a</span><span style="color: Gray;">&gt;&nbsp; <br />&lt;</span><span style="color: Blue;">a</span><span style="color: Gray;"> </span><span style="color: Blue;">href</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Green;">class</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Styleswitcher</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Blue;">rel</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">blue.css</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&gt;</span><span style="color: Blue;">Blue</span><span style="color: Gray;"> </span><span style="color: Blue;">Theme</span><span style="color: Gray;">&lt;</span><span style="color: #8b0000;">/</span><span style="color: Red;">a&gt;</span></div>
</div>
<p><strong>6、高度相等的列</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">function</span><span style="color: Gray;"> </span><span style="color: Blue;">equalHeight</span><span style="color: Olive;">(</span><span style="color: Blue;">group</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">tallest</span><span style="color: Gray;"> = </span><span style="color: Maroon;">0</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">group</span><span style="color: Gray;">.</span><span style="color: Blue;">each</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">thisHeight</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">()</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Olive;">(</span><span style="color: Blue;">thisHeight</span><span style="color: Gray;"> &gt; </span><span style="color: Blue;">tallest</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">tallest</span><span style="color: Gray;"> = </span><span style="color: Blue;">thisHeight</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">group</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">(</span><span style="color: Blue;">tallest</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// how to use&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">equalHeight</span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.left</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">))</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">equalHeight</span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.right</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">))</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>7、简单字体变大缩小</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: #ffa500;">// Reset the font size(back to default)</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">originalFontSize</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">html</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">font-size</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.resetFont</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">html</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">font-size</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">, </span><span style="color: Blue;">originalFontSize</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br />&nbsp; </span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br />&nbsp; </span><span style="color: #ffa500;">// Increase the font size(bigger font0</span><span style="color: Gray;"><br />&nbsp; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.increaseFont</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">currentFontSize</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">html</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">font-size</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">currentFontSizeNum</span><span style="color: Gray;"> = </span><span style="color: Blue;">parseFloat</span><span style="color: Olive;">(</span><span style="color: Blue;">currentFontSize</span><span style="color: Gray;">, </span><span style="color: Maroon;">10</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">newFontSize</span><span style="color: Gray;"> = </span><span style="color: Blue;">currentFontSizeNum</span><span style="color: Gray;">*</span><span style="color: Maroon;">1.2</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">html</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">font-size</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">, </span><span style="color: Blue;">newFontSize</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">false</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br />&nbsp; </span><span style="color: #ffa500;">// Decrease the font size(smaller font)&nbsp; </span><span style="color: Gray;"><br />&nbsp; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">.decreaseFont</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">currentFontSize</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">html</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">font-size</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">currentFontSizeNum</span><span style="color: Gray;"> = </span><span style="color: Blue;">parseFloat</span><span style="color: Olive;">(</span><span style="color: Blue;">currentFontSize</span><span style="color: Gray;">, </span><span style="color: Maroon;">10</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">newFontSize</span><span style="color: Gray;"> = </span><span style="color: Blue;">currentFontSizeNum</span><span style="color: Gray;">*</span><span style="color: Maroon;">0.8</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">html</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">font-size</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">, </span><span style="color: Blue;">newFontSize</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">false</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>8、返回头部滑动动画</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">a[href*=#]</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Blue;">location</span><span style="color: Gray;">.</span><span style="color: Blue;">pathname</span><span style="color: Gray;">.</span><span style="color: Blue;">replace</span><span style="color: Olive;">(</span><span style="color: #8b0000;">/</span><span style="color: Red;">^</span><span style="color: Navy;">\/</span><span style="color: #8b0000;">/</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&#8221;</span><span style="color: Olive;">)</span><span style="color: Gray;"> == </span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">pathname</span><span style="color: Gray;">.</span><span style="color: Blue;">replace</span><span style="color: Olive;">(</span><span style="color: #8b0000;">/</span><span style="color: Red;">^</span><span style="color: Navy;">\/</span><span style="color: #8b0000;">/</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&#8221;</span><span style="color: Olive;">)</span><span style="color: Gray;"> &amp;&amp; </span><span style="color: Blue;">location</span><span style="color: Gray;">.</span><span style="color: Blue;">hostname</span><span style="color: Gray;"> == </span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">hostname</span><span style="color: Olive;">){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> $</span><span style="color: Blue;">target</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">hash</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Blue;">target</span><span style="color: Gray;"> = $</span><span style="color: Blue;">target</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Gray;"> &amp;&amp; $</span><span style="color: Blue;">target</span><span style="color: Gray;"> || $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">[name=</span><span style="color: #8b0000;">'</span><span style="color: Gray;"> + </span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">hash</span><span style="color: Gray;">.</span><span style="color: Blue;">slice</span><span style="color: Olive;">(</span><span style="color: Maroon;">1</span><span style="color: Olive;">)</span><span style="color: Gray;"> +</span><span style="color: #8b0000;">'</span><span style="color: Red;">]</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Blue;">target</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Olive;">){</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">targetOffset</span><span style="color: Gray;"> = $</span><span style="color: Blue;">target</span><span style="color: Gray;">.</span><span style="color: Blue;">offset</span><span style="color: Olive;">()</span><span style="color: Gray;">.</span><span style="color: Blue;">top</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">html,body</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">animate</span><span style="color: Olive;">({</span><span style="color: Blue;">scrollTop</span><span style="color: Gray;">: </span><span style="color: Blue;">targetOffset</span><span style="color: Olive;">}</span><span style="color: Gray;">, </span><span style="color: Maroon;">500</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">false</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;<br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;<br />&nbsp;<br />&nbsp;<br />&lt;</span><span style="color: Blue;">a</span><span style="color: Gray;"> </span><span style="color: Blue;">name</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">top</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&gt;&lt;</span><span style="color: #8b0000;">/</span><span style="color: Red;">a&gt;&nbsp; <br /></span><span style="color: #8b0000;">//</span><span style="color: Red;"> the link&nbsp; <br />&lt;a href=&quot;#top&quot;&gt;go to top&lt;</span><span style="color: #8b0000;">/</span><span style="color: Blue;">a</span><span style="color: Gray;">&gt;</span></div>
</div>
<p><strong>9、获取鼠标位置</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">html</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">mousemove</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">e</span><span style="color: Olive;">){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//display the x and y axis values inside the div with the id XY&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#XY</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">html</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">X Axis : </span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> + </span><span style="color: Blue;">e</span><span style="color: Gray;">.</span><span style="color: Blue;">pageX</span><span style="color: Gray;"> + </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;"> | Y Axis </span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> + </span><span style="color: Blue;">e</span><span style="color: Gray;">.</span><span style="color: Blue;">pageY</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;<br />&nbsp;<br />&lt;</span><span style="color: Blue;">div</span><span style="color: Gray;"> </span><span style="color: Blue;">id</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">XY</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&gt;&lt;</span><span style="color: #8b0000;">/</span><span style="color: Red;">div&gt;</span></div>
</div>
<p><strong>10、判断一个元素是否为空</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#id</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">html</span><span style="color: Olive;">())</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">// do something&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></div>
</div>
<p><strong>11、替换元素</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#id</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">replaceWith</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">&lt;div&gt;I have been replaced&lt;/div&gt;</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>12、jquery timer 返回函数</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; </span><span style="color: Teal;">window</span><span style="color: Gray;">.</span><span style="color: Blue;">setTimeout</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; </span><span style="color: #ffa500;">// do something&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">, </span><span style="color: Maroon;">1000</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>13、jquery也玩替换</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; </span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">el</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#id</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; </span><span style="color: Blue;">el</span><span style="color: Gray;">.</span><span style="color: Blue;">html</span><span style="color: Olive;">(</span><span style="color: Blue;">el</span><span style="color: Gray;">.</span><span style="color: Blue;">html</span><span style="color: Olive;">()</span><span style="color: Gray;">.</span><span style="color: Blue;">replace</span><span style="color: Olive;">(</span><span style="color: #8b0000;">/</span><span style="color: Red;">word</span><span style="color: #8b0000;">/i</span><span style="color: Blue;">g</span><span style="color: Gray;">, </span><span style="color: #8b0000;">&quot;&quot;</span><span style="color: Olive;">))</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>14、判断元素是否存在</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; </span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#id</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">length</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp; </span><span style="color: #ffa500;">// do something&nbsp; </span><span style="color: Gray;"><br />&nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>15、让div也可以click</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">div</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//get the url from href attribute and launch the url&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Teal;">window</span><span style="color: Gray;">.</span><span style="color: Blue;">location</span><span style="color: Gray;">=$</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">find</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">a</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">attr</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">href</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">false</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;<br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;<br />&nbsp;<br />&lt;</span><span style="color: Blue;">div</span><span style="color: Gray;">&gt;&lt;</span><span style="color: Blue;">a</span><span style="color: Gray;"> </span><span style="color: Blue;">href</span><span style="color: Gray;">=</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">index.html</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">&gt;</span><span style="color: Blue;">home</span><span style="color: Gray;">&lt;</span><span style="color: #8b0000;">/</span><span style="color: Red;">a&gt;&lt;</span><span style="color: #8b0000;">/</span><span style="color: Blue;">div</span><span style="color: Gray;">&gt;</span></div>
</div>
<p><strong>16、判断浏览器类型</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; </span><span style="color: Green;">function</span><span style="color: Gray;"> </span><span style="color: Blue;">checkWindowSize</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">if</span><span style="color: Gray;"> </span><span style="color: Olive;">(</span><span style="color: Gray;"> $</span><span style="color: Olive;">(</span><span style="color: Teal;">window</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">width</span><span style="color: Olive;">()</span><span style="color: Gray;"> &gt; </span><span style="color: Maroon;">1200</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">body</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">addClass</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">large</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">else</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">body</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">removeClass</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">large</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br />$</span><span style="color: Olive;">(</span><span style="color: Teal;">window</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">resize</span><span style="color: Olive;">(</span><span style="color: Blue;">checkWindowSize</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>17、几个字符就clone！</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp;</span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">cloned</span><span style="color: Gray;"> = $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#id</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">clone</span><span style="color: Olive;">()</span><span style="color: Gray;"><br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>18、设置div在屏幕中央</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; </span><span style="color: Blue;">jQuery</span><span style="color: Gray;">.</span><span style="color: Blue;">fn</span><span style="color: Gray;">.</span><span style="color: Blue;">center</span><span style="color: Gray;"> = </span><span style="color: Green;">function</span><span style="color: Gray;"> </span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">position</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">absolute</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">top</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Teal;">window</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">()</span><span style="color: Gray;">-</span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">())</span><span style="color: Gray;"> </span><span style="color: #8b0000;">/</span><span style="color: Red;"> 2+$(window).scrollTop() + &quot;px&quot;);<br />&nbsp;&nbsp; &nbsp; &nbsp; this.css(&quot;left&quot;, ($(window).width()-this.width()) </span><span style="color: #8b0000;">/</span><span style="color: Gray;"> </span><span style="color: Maroon;">2</span><span style="color: Gray;">+$</span><span style="color: Olive;">(</span><span style="color: Teal;">window</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">scrollLeft</span><span style="color: Olive;">()</span><span style="color: Gray;"> + </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">px</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br />&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Green;">this</span><span style="color: Gray;">;<br />&nbsp;&nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;"><br />&nbsp;&nbsp; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#id</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">center</span><span style="color: Olive;">()</span><span style="color: Gray;">;<br />&nbsp;</span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>19、创建自己的选择器</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; $.</span><span style="color: Blue;">extend</span><span style="color: Olive;">(</span><span style="color: Gray;">$.</span><span style="color: Blue;">expr</span><span style="color: Olive;">[</span><span style="color: #8b0000;">'</span><span style="color: Red;">:</span><span style="color: #8b0000;">'</span><span style="color: Olive;">]</span><span style="color: Gray;">, </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">moreThen1000px</span><span style="color: Gray;">: </span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">a</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">return</span><span style="color: Gray;"> $</span><span style="color: Olive;">(</span><span style="color: Blue;">a</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">width</span><span style="color: Olive;">()</span><span style="color: Gray;"> &gt; </span><span style="color: Maroon;">1000</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; </span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br />&nbsp; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">.box:moreThen1000px</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">// creating a simple js alert box&nbsp; </span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp;</span><span style="color: Blue;">alert</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">The element that you have clicked is over 1000 pixels wide</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br />&nbsp; </span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>20、计算元素的数目</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">p</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">size</span><span style="color: Olive;">()</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>21、设置自己的li样式</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">ul</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">addClass</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Replaced</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">ul &gt; li</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">prepend</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">‒ </span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br />&nbsp;</span><span style="color: #ffa500;">// how to use&nbsp; </span><span style="color: Gray;"><br />&nbsp;</span><span style="color: Blue;">ul</span><span style="color: Gray;">.</span><span style="color: Blue;">Replaced</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;"> </span><span style="color: Blue;">list</span><span style="color: Gray;">-</span><span style="color: Blue;">style</span><span style="color: Gray;"> : </span><span style="color: Blue;">none</span><span style="color: Gray;">; </span><span style="color: Olive;">}</span><span style="color: Gray;">&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>22、关闭jquery动画效果</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; &nbsp;</span><span style="color: Blue;">jQuery</span><span style="color: Gray;">.</span><span style="color: Blue;">fx</span><span style="color: Gray;">.</span><span style="color: Blue;">off</span><span style="color: Gray;"> = </span><span style="color: Green;">true</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>23、使用自己的jquery标识</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">()</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span><span style="color: Gray;">&nbsp; <br />&nbsp;&nbsp; </span><span style="color: Green;">var</span><span style="color: Gray;"> $</span><span style="color: Blue;">jq</span><span style="color: Gray;"> = </span><span style="color: Blue;">jQuery</span><span style="color: Gray;">.</span><span style="color: Blue;">noConflict</span><span style="color: Olive;">()</span><span style="color: Gray;">;&nbsp; <br />&nbsp;&nbsp; $</span><span style="color: Blue;">jq</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">#id</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">show</span><span style="color: Olive;">()</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>24、解决自定义方法或其他类库与jQuery的冲突</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Blue;">jQuery</span><span style="color: Gray;">.</span><span style="color: Blue;">noConflict</span><span style="color: Olive;">()</span><span style="color: Gray;">; <br /></span><span style="color: #ffa500;">// 开始使用jQuery</span><span style="color: Gray;"><br /></span><span style="color: Blue;">jQuery</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">div p</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">hide</span><span style="color: Olive;">()</span><span style="color: Gray;">;<br /></span><span style="color: #ffa500;">// 使用其他库的 $() </span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">content</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">style</span><span style="color: Gray;">.</span><span style="color: Blue;">display</span><span style="color: Gray;"> = </span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">none</span><span style="color: #8b0000;">&#8216;</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>25、如何获取jQuery集合的某一项</strong><br />
对于获取的元素集合，获取其中的某一项（通过索引指定）可以使用eq或get(n)方法或者索引号获取，要注意，eq返回的是jquery对象，而 get(n)和索引返回的是dom元素对象。对于jquery对象只能使用jquery的方法，而dom对象只能使用dom的方法，如要获取第三个div元素的内容。有如下两种方法：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">div</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">eq</span><span style="color: Olive;">(</span><span style="color: Maroon;">2</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">html</span><span style="color: Olive;">()</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//调用jquery对象的方法</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">div</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">get</span><span style="color: Olive;">(</span><span style="color: Maroon;">2</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">innerHTML</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//调用dom的方法属性</span></div>
</div>
<p><strong>26、同一函数实现set和get</strong><br />
Jquery中的很多方法都是如此，主要包括如下几个：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">html</span><span style="color: Olive;">()</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//返回id为msg的元素节点的html内容。</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">html</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">&lt;b&gt;new content&lt;/b&gt;</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; <br /></span><span style="color: #ffa500;">//将“&lt;b&gt;new content&lt;/b&gt;” 作为html串写入id为msg的元素节点内容中,页面显示粗体的new content</span><span style="color: Gray;"><br />&nbsp;<br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">text</span><span style="color: Olive;">()</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//返回id为msg的元素节点的文本内容。</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">text</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">&lt;b&gt;new content&lt;/b&gt;</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; <br /></span><span style="color: #ffa500;">//将“&lt;b&gt;new content&lt;/b&gt;” 作为普通文本串写入id为msg的元素节点内容中,页面显示&lt;b&gt;new content&lt;/b&gt;</span><span style="color: Gray;"><br />&nbsp;<br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">()</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//返回id为msg的元素的高度</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">300</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//将id为msg的元素的高度设为300</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">width</span><span style="color: Olive;">()</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//返回id为msg的元素的宽度</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">width</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">300</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//将id为msg的元素的宽度设为300</span><span style="color: Gray;"><br />&nbsp;<br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">input</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">val</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">);&nbsp; &nbsp; &nbsp; &nbsp;//返回表单输入框的value值<br />$(</span><span style="color: #8b0000;">&quot;</span><span style="color: Blue;">input</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">).val(</span><span style="color: #8b0000;">&quot;</span><span style="color: Blue;">test</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">);&nbsp; &nbsp; &nbsp; &nbsp;//将表单输入框的value值设为test<br />&nbsp;<br />$(</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">#</span><span style="color: Blue;">msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">).click();&nbsp; &nbsp; &nbsp; &nbsp;//触发id为msg的元素的单击事件<br />$(</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">#</span><span style="color: Blue;">msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">).click(fn);&nbsp; &nbsp; &nbsp; &nbsp;//为id为msg的元素单击事件添加函数</span></div>
</div>
<p>同样blur,focus,select,submit事件都可以有这两种调用方法</p>
<p><strong>27、集合处理功能</strong><br />
对于jquery返回的集合内容无需我们自己循环遍历并对每个对象分别做处理，jquery已经为我们提供的很方便的方法进行集合的处理。<br />
包括两种形式：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">p</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">each</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">i</span><span style="color: Olive;">){</span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">style</span><span style="color: Gray;">.</span><span style="color: Blue;">color</span><span style="color: Gray;">=</span><span style="color: Olive;">[</span><span style="color: #8b0000;">'</span><span style="color: Red;">#f00</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">#0f0</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">#00f</span><span style="color: #8b0000;">'</span><span style="color: Olive;">][</span><span style="color: Blue;">i</span><span style="color: Olive;">]})</span><span style="color: Gray;">&nbsp; &nbsp; &nbsp; <br /></span><span style="color: #ffa500;">//为索引分别为0，1，2的p元素分别设定不同的字体颜色。</span><span style="color: Gray;"><br />&nbsp;<br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">tr</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">each</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">i</span><span style="color: Olive;">){</span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">style</span><span style="color: Gray;">.</span><span style="color: Blue;">backgroundColor</span><span style="color: Gray;">=</span><span style="color: Olive;">[</span><span style="color: #8b0000;">'</span><span style="color: Red;">#ccc</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">#fff</span><span style="color: #8b0000;">'</span><span style="color: Olive;">][</span><span style="color: Blue;">i</span><span style="color: Gray;">%</span><span style="color: Maroon;">2</span><span style="color: Olive;">]})</span><span style="color: Gray;">&nbsp; &nbsp; &nbsp; <br /></span><span style="color: #ffa500;">//实现表格的隔行换色效果</span><span style="color: Gray;"><br />&nbsp;<br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">p</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Blue;">alert</span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">html</span><span style="color: Olive;">())})</span><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br /></span><span style="color: #ffa500;">//为每个p元素增加了click事件，单击某个p元素则弹出其内容</span></div>
</div>
<p><strong>28、扩展我们需要的功能</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$.</span><span style="color: Blue;">extend</span><span style="color: Olive;">({</span><span style="color: Gray;"><br />&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">min</span><span style="color: Gray;">: </span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">a</span><span style="color: Gray;">, </span><span style="color: Blue;">b</span><span style="color: Olive;">){</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Blue;">a</span><span style="color: Gray;"> &lt; </span><span style="color: Blue;">b</span><span style="color: Gray;">?</span><span style="color: Blue;">a</span><span style="color: Gray;">:</span><span style="color: Blue;">b</span><span style="color: Gray;">; </span><span style="color: Olive;">}</span><span style="color: Gray;">,<br />&nbsp;&nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">max</span><span style="color: Gray;">: </span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">a</span><span style="color: Gray;">, </span><span style="color: Blue;">b</span><span style="color: Olive;">){</span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Blue;">a</span><span style="color: Gray;"> &gt; </span><span style="color: Blue;">b</span><span style="color: Gray;">?</span><span style="color: Blue;">a</span><span style="color: Gray;">:</span><span style="color: Blue;">b</span><span style="color: Gray;">; </span><span style="color: Olive;">}</span><span style="color: Gray;"><br /></span><span style="color: Olive;">})</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//为jquery扩展了min,max两个方法</span></div>
</div>
<p>使用扩展的方法（通过“$.方法名”调用）：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Blue;">alert</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">a=10,b=20,max=</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">+$.</span><span style="color: Blue;">max</span><span style="color: Olive;">(</span><span style="color: Maroon;">10</span><span style="color: Gray;">,</span><span style="color: Maroon;">20</span><span style="color: Olive;">)</span><span style="color: Gray;">+</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">,min=</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">+$.</span><span style="color: Blue;">min</span><span style="color: Olive;">(</span><span style="color: Maroon;">10</span><span style="color: Gray;">,</span><span style="color: Maroon;">20</span><span style="color: Olive;">))</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>29、支持方法的连写</strong><br />
所谓连写，即可以对一个jquery对象连续调用各种不同的方法。</p>
<p>例如：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">p</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">click</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Blue;">alert</span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">html</span><span style="color: Olive;">())})</span><span style="color: Gray;"><br />.</span><span style="color: Blue;">mouseover</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(){</span><span style="color: Blue;">alert</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&#8216;</span><span style="color: Red;">mouse over event</span><span style="color: #8b0000;">&#8216;</span><span style="color: Olive;">)})</span><span style="color: Gray;"><br />.</span><span style="color: Blue;">each</span><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">i</span><span style="color: Olive;">){</span><span style="color: Green;">this</span><span style="color: Gray;">.</span><span style="color: Blue;">style</span><span style="color: Gray;">.</span><span style="color: Blue;">color</span><span style="color: Gray;">=</span><span style="color: Olive;">[</span><span style="color: #8b0000;">'</span><span style="color: Red;">#f00</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">#0f0</span><span style="color: #8b0000;">'</span><span style="color: Gray;">,</span><span style="color: #8b0000;">'</span><span style="color: Red;">#00f</span><span style="color: #8b0000;">'</span><span style="color: Olive;">][</span><span style="color: Blue;">i</span><span style="color: Olive;">]})</span><span style="color: Gray;">;</span></div>
</div>
<p><strong>30、操作元素的样式</strong><br />
主要包括以下几种方式：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">background</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #ffa500;">//返回元素的背景颜色</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">background</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#ccc</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//设定元素背景为灰色</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">height</span><span style="color: Olive;">(</span><span style="color: Maroon;">300</span><span style="color: Olive;">)</span><span style="color: Gray;">; $</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">width</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">200</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//设定宽高</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">css</span><span style="color: Olive;">({</span><span style="color: Gray;"> </span><span style="color: Blue;">color</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">red</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">, </span><span style="color: Blue;">background</span><span style="color: Gray;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">blue</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> </span><span style="color: Olive;">})</span><span style="color: Gray;">;</span><span style="color: #ffa500;">//以名值对的形式设定样式</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">addClass</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">select</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//为元素增加名称为select的class</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">removeClass</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">select</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//删除元素名称为select的class</span><span style="color: Gray;"><br />$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#msg</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">toggleClass</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">select</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//如果存在（不存在）就删除（添加）名称为select的class</span></div>
</div>
<p><strong>31、几个实用特效功能</strong></p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">其中</span><span style="color: Blue;">toggle</span><span style="color: Olive;">()</span><span style="color: Gray;">和</span><span style="color: Blue;">slidetoggle</span><span style="color: Olive;">()</span><span style="color: Gray;">方法提供了状态切换功能。<br />如</span><span style="color: Blue;">toggle</span><span style="color: Olive;">()</span><span style="color: Gray;">方法包括了</span><span style="color: Blue;">hide</span><span style="color: Olive;">()</span><span style="color: Gray;">和</span><span style="color: Blue;">show</span><span style="color: Olive;">()</span><span style="color: Gray;">方法。<br /></span><span style="color: Blue;">slideToggle</span><span style="color: Olive;">()</span><span style="color: Gray;">方法包括了</span><span style="color: Blue;">slideDown</span><span style="color: Olive;">()</span><span style="color: Gray;">和</span><span style="color: Blue;">slideUp</span><span style="color: Gray;">方法。</span></div>
</div>
<p><strong>32、几个有用的jQuery方法</strong><br />
<span>$.each(obj, fn)：</span>通用的迭代函数。可用于近似地迭代对象和数组（代替循环）。<br />
如</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$.</span><span style="color: Blue;">each</span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: Olive;">[</span><span style="color: Maroon;">0</span><span style="color: Gray;">,</span><span style="color: Maroon;">1</span><span style="color: Gray;">,</span><span style="color: Maroon;">2</span><span style="color: Olive;">]</span><span style="color: Gray;">, </span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">i</span><span style="color: Gray;">, </span><span style="color: Blue;">n</span><span style="color: Olive;">){</span><span style="color: Gray;"> </span><span style="color: Blue;">alert</span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">Item #</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> + </span><span style="color: Blue;">i</span><span style="color: Gray;"> + </span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">: </span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;"> + </span><span style="color: Blue;">n</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;">; </span><span style="color: Olive;">})</span><span style="color: Gray;">;</span></div>
</div>
<p><span>$.extend(target,prop1,propN)：</span>用一个或多个其他对象来扩展一个对象，返回这个被扩展的对象。这是jquery实现的继承方式。<br />
如：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$.</span><span style="color: Blue;">extend</span><span style="color: Olive;">(</span><span style="color: Blue;">settings</span><span style="color: Gray;">, </span><span style="color: Blue;">options</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; <br /></span><span style="color: #ffa500;">//合并settings和options，并将合并结果返回settings中，相当于options继承setting并将继承结果保存在setting中。</span><span style="color: Gray;"><br /></span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">settings</span><span style="color: Gray;"> = $.</span><span style="color: Blue;">extend</span><span style="color: Olive;">({}</span><span style="color: Gray;">, </span><span style="color: Blue;">defaults</span><span style="color: Gray;">, </span><span style="color: Blue;">options</span><span style="color: Olive;">)</span><span style="color: Gray;">;<br /></span><span style="color: #ffa500;">//合并defaults和options，并将合并结果返回到setting中而不覆盖default内容。</span><span style="color: Gray;"><br />可以有多个参数（合并多项并返回）</span></div>
</div>
<p><span>$.map(array, fn)：</span>数组映射。把一个数组中的项目(处理转换后)保存到到另一个新数组中，并返回生成的新数组。<br />
如：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">tempArr</span><span style="color: Gray;">=$.</span><span style="color: Blue;">map</span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: Olive;">[</span><span style="color: Maroon;">0</span><span style="color: Gray;">,</span><span style="color: Maroon;">1</span><span style="color: Gray;">,</span><span style="color: Maroon;">2</span><span style="color: Olive;">]</span><span style="color: Gray;">, </span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">i</span><span style="color: Olive;">){</span><span style="color: Gray;"> </span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Blue;">i</span><span style="color: Gray;"> + </span><span style="color: Maroon;">4</span><span style="color: Gray;">; </span><span style="color: Olive;">})</span><span style="color: Gray;">;<br /></span><span style="color: Blue;">tempArr</span><span style="color: Gray;">内容为：</span><span style="color: Olive;">[</span><span style="color: Maroon;">4</span><span style="color: Gray;">,</span><span style="color: Maroon;">5</span><span style="color: Gray;">,</span><span style="color: Maroon;">6</span><span style="color: Olive;">]</span><span style="color: Gray;"><br /></span><span style="color: Green;">var</span><span style="color: Gray;"> </span><span style="color: Blue;">tempArr</span><span style="color: Gray;">=$.</span><span style="color: Blue;">map</span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: Olive;">[</span><span style="color: Maroon;">0</span><span style="color: Gray;">,</span><span style="color: Maroon;">1</span><span style="color: Gray;">,</span><span style="color: Maroon;">2</span><span style="color: Olive;">]</span><span style="color: Gray;">, </span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">i</span><span style="color: Olive;">){</span><span style="color: Gray;"> </span><span style="color: Green;">return</span><span style="color: Gray;"> </span><span style="color: Blue;">i</span><span style="color: Gray;"> &gt; </span><span style="color: Maroon;">0</span><span style="color: Gray;"> ? </span><span style="color: Blue;">i</span><span style="color: Gray;"> + </span><span style="color: Maroon;">1</span><span style="color: Gray;"> : </span><span style="color: Green;">null</span><span style="color: Gray;">; </span><span style="color: Olive;">})</span><span style="color: Gray;">;<br /></span><span style="color: Blue;">tempArr</span><span style="color: Gray;">内容为：</span><span style="color: Olive;">[</span><span style="color: Maroon;">2</span><span style="color: Gray;">,</span><span style="color: Maroon;">3</span><span style="color: Olive;">]</span></div>
</div>
<p><span>$.merge(arr1,arr2):</span>合并两个数组并删除其中重复的项目。<br />
如：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$.</span><span style="color: Blue;">merge</span><span style="color: Olive;">(</span><span style="color: Gray;"> </span><span style="color: Olive;">[</span><span style="color: Maroon;">0</span><span style="color: Gray;">,</span><span style="color: Maroon;">1</span><span style="color: Gray;">,</span><span style="color: Maroon;">2</span><span style="color: Olive;">]</span><span style="color: Gray;">, </span><span style="color: Olive;">[</span><span style="color: Maroon;">2</span><span style="color: Gray;">,</span><span style="color: Maroon;">3</span><span style="color: Gray;">,</span><span style="color: Maroon;">4</span><span style="color: Olive;">]</span><span style="color: Gray;"> </span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp;</span><span style="color: #ffa500;">//返回[0,1,2,3,4]</span></div>
</div>
<p><span>$.trim(str)：</span>删除字符串两端的空白字符。<br />
如：</p>
<div class="hl-surround">
<div class="hl-main"><span style="color: Gray;">$.</span><span style="color: Blue;">trim</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">&nbsp; hello, how are you?&nbsp; &nbsp;</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">;&nbsp; &nbsp; </span><span style="color: #ffa500;">//返回&quot;hello,how are you? &quot;</span></div>
</div>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=1270" title="各种jquery实例效果">各种jquery实例效果</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1022" title="各种jQuery插件">各种jQuery插件</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=945" title="各种Javascript技巧">各种Javascript技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=184" title="各种CSS bug与技巧 更新为2010.3.5">各种CSS bug与技巧 更新为2010.3.5</a> (11)</li><li><a href="http://www.hemin.cn/blog/?p=44" title="各种浏览器css hack  更新为2009.8.7">各种浏览器css hack  更新为2009.8.7</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=339" title="各种html+CSS实例效果 更新为2010.7.27">各种html+CSS实例效果 更新为2010.7.27</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=341" title="各种javascript实例效果 更新为2010.07.26">各种javascript实例效果 更新为2010.07.26</a> (4)</li><li><a href="http://www.hemin.cn/blog/?p=1354" title="tudou首页图片延迟加载">tudou首页图片延迟加载</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1333" title="CSS清除浮动">CSS清除浮动</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1313" title="jQuery性能优化">jQuery性能优化</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1286</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>javascript字符串反转</title>
		<link>http://www.hemin.cn/blog/?p=1284</link>
		<comments>http://www.hemin.cn/blog/?p=1284#comments</comments>
		<pubDate>Sun, 04 Jul 2010 10:44:32 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[JS/JQuery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[反转]]></category>
		<category><![CDATA[字符]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1284</guid>
		<description><![CDATA[周五遇到这面试题回家做了下记录下。 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62; &#60;title&#62;javascript字符串反转 &#60;/title&#62; &#60;script type=&#34;text/javascript&#34;&#62; var hemin = &#34;www.hemin.cn&#34;; //document.write(hemin.split(&#34;&#34;).reverse().join(&#34;&#34;).toString());//用reverse()转 var hmsz = []; for(var i=hemin.length-1; i&#62;-1; i--){ hmsz.push(hemin.charAt(i)); } document.write(hmsz.join(&#34;&#34;).toString()); &#60;/script&#62; &#60;/head&#62; &#60;body&#62; &#60;/body&#62; &#60;/html&#62; 提示：你可以先修改部分代码再运行。 相关文章：javascript替换字符 (0)各种javascript实例效果 更新为2010.07.26 (4)10个javascript Frameworks 外连 (0)物体碰撞反弹与圆周运动 (0)百度2010校园招聘前端开发笔试题 (6)08年阿里巴巴前端开发面试题 (6)我推荐的书籍 (0)各种Javascript技巧 (0)JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p>周五遇到这面试题回家做了下记录下。</p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_JyE6Tw">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;javascript字符串反转 &lt;/title&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	var hemin = &quot;www.hemin.cn&quot;;
	//document.write(hemin.split(&quot;&quot;).reverse().join(&quot;&quot;).toString());//用reverse()转
	var hmsz = [];
	for(var i=hemin.length-1; i&gt;-1; i--){
			hmsz.push(hemin.charAt(i));
		}
	document.write(hmsz.join(&quot;&quot;).toString());
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_JyE6Tw');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_JyE6Tw');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_JyE6Tw','runcode_JyE6Tw');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=703" title="javascript替换字符">javascript替换字符</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=341" title="各种javascript实例效果 更新为2010.07.26">各种javascript实例效果 更新为2010.07.26</a> (4)</li><li><a href="http://www.hemin.cn/blog/?p=1203" title="10个javascript Frameworks 外连">10个javascript Frameworks 外连</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1122" title="物体碰撞反弹与圆周运动">物体碰撞反弹与圆周运动</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1104" title="百度2010校园招聘前端开发笔试题">百度2010校园招聘前端开发笔试题</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=1099" title="08年阿里巴巴前端开发面试题">08年阿里巴巴前端开发面试题</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=1068" title="我推荐的书籍">我推荐的书籍</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=945" title="各种Javascript技巧">各种Javascript技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=907" title="JavaScript 快速组合算法">JavaScript 快速组合算法</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=880" title="入门JavaScript正则表达式">入门JavaScript正则表达式</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1284</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>妈妈告诉我的细节</title>
		<link>http://www.hemin.cn/blog/?p=1235</link>
		<comments>http://www.hemin.cn/blog/?p=1235#comments</comments>
		<pubDate>Thu, 24 Jun 2010 04:49:39 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[生活记载]]></category>
		<category><![CDATA[细节]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1235</guid>
		<description><![CDATA[1.去别人家里，不要坐在人家的床上 。 2.在酒桌上与别人碰杯，自己的杯子一定要低于对方的，特别是对方是长辈或领导 。 3.晴带雨伞，饱带干粮&#8212;未雨绸缪总是好的。 4. 如果问别人话，别人不回答你，不要死着脸皮不停的问。 5. 吃饭的时候尽量不要发出声音。 6. 捡东西或者穿鞋时候要蹲下去，不要弯腰撅屁股。 7. 别人批评你的时候，即使他是错的，也不要先辨驳，等大家都平静下来再解释 。 8.做事情要适可而止,无论是狂吃喜欢的食物还是闹脾气 。 9.到朋友家吃完饭,要主动帮忙洗碗清理桌子&#8212;&#8211;主人做饭已经很辛苦了,不能事后还让主人清理。 10.生活中会遇见各式各样的人,你不可能与每个人都合拍,但是有一点是四海皆准的:你如何对待别人,别人也会如何对待你 。 11.待客不得不大，持家不得不小 。 12.把拳头收回来是为了更有力的还击 13.人活在这个世上，首先要学会一个 “忍”字。 14.任何时候对任何人不要轻易告诉对方你的秘密 。 15.钱不是靠攒的，会花才会赚 。 16.学无止境，不仅仅是学书本知识，更要学会怎么待人处事，社会远比你想象的要复杂 。 17.不要跟同事议论上司或其他同事的是非，你的无心之言很可能成为别人打击你的证据。 18.做事情，做好了是你的本分，做的不好就是你失职 。 19.只有错买，没有错卖。不要只顾着贪小便宜。 20.有时候孤单是正常的，不要害怕，要自己调剂 21.有真正的朋友，但不知你有没有福气遇到。不管有没有遇到，都不要否认它。不要算计别人，尤其不要算计自己喜欢的人。对自己喜欢的人，不要使用手段去得到 。 22.最勇敢的事情是认清了生活的真相之后依旧热爱生活。不要害怕欺骗，但要知道世界上存在欺骗 。 23.借钱的时候，心里要有个底，就是要想着这个钱是回不来的。所以借出去的钱永远要在自己能承受的损失范围之内。可以承受的数字以内，即使回不来，也是心里早准备好的。自己不能承受损失的数目，就不能借。 24.最好的朋友之间，除非他穷的吃不了饭了，否则最好不要有经济往来。许多可贵的友谊都败坏在钱上。 25.君子可寓意于物，但不可留意于物 。 26.出门在外能忍则忍，退一步海阔天空。 27.擦桌子的时候要往自己的方向抹 。 28.打电话接电话第一句话一定要是 喂，您好；挂电话的时候等别人先挂。 29.一次不忠 百次不容。 30.不随地吐痰扔东西，如果没有垃圾箱，就拎回家扔垃圾筒里。 31.多看书对心灵有益,你会看到一个更广阔的世界 。 32.是你去适应社会,不是社会来适应你。 33.不要让别人知道自己的真实想法,要笑在人前笑, [...]]]></description>
			<content:encoded><![CDATA[<p>1.去别人家里，不要坐在人家的床上 。<br />
2.在酒桌上与别人碰杯，自己的杯子一定要低于对方的，特别是对方是长辈或领导 。<br />
3.晴带雨伞，饱带干粮&#8212;未雨绸缪总是好的。<br />
4. 如果问别人话，别人不回答你，不要死着脸皮不停的问。<br />
5. 吃饭的时候尽量不要发出声音。<br />
<span id="more-1235"></span><br />
6. 捡东西或者穿鞋时候要蹲下去，不要弯腰撅屁股。<br />
7. 别人批评你的时候，即使他是错的，也不要先辨驳，等大家都平静下来再解释 。<br />
8.做事情要适可而止,无论是狂吃喜欢的食物还是闹脾气 。<br />
9.到朋友家吃完饭,要主动帮忙洗碗清理桌子&#8212;&#8211;主人做饭已经很辛苦了,不能事后还让主人清理。<br />
10.生活中会遇见各式各样的人,你不可能与每个人都合拍,但是有一点是四海皆准的:你如何对待别人,别人也会如何对待你 。<br />
11.待客不得不大，持家不得不小 。<br />
12.把拳头收回来是为了更有力的还击<br />
13.人活在这个世上，首先要学会一个 “忍”字。<br />
14.任何时候对任何人不要轻易告诉对方你的秘密 。<br />
15.钱不是靠攒的，会花才会赚 。<br />
16.学无止境，不仅仅是学书本知识，更要学会怎么待人处事，社会远比你想象的要复杂 。<br />
17.不要跟同事议论上司或其他同事的是非，你的无心之言很可能成为别人打击你的证据。<br />
18.做事情，做好了是你的本分，做的不好就是你失职 。<br />
19.只有错买，没有错卖。不要只顾着贪小便宜。<br />
20.有时候孤单是正常的，不要害怕，要自己调剂<br />
21.有真正的朋友，但不知你有没有福气遇到。不管有没有遇到，都不要否认它。不要算计别人，尤其不要算计自己喜欢的人。对自己喜欢的人，不要使用手段去得到 。<br />
22.最勇敢的事情是认清了生活的真相之后依旧热爱生活。不要害怕欺骗，但要知道世界上存在欺骗 。<br />
23.借钱的时候，心里要有个底，就是要想着这个钱是回不来的。所以借出去的钱永远要在自己能承受的损失范围之内。可以承受的数字以内，即使回不来，也是心里早准备好的。自己不能承受损失的数目，就不能借。<br />
24.最好的朋友之间，除非他穷的吃不了饭了，否则最好不要有经济往来。许多可贵的友谊都败坏在钱上。<br />
25.君子可寓意于物，但不可留意于物 。<br />
26.出门在外能忍则忍，退一步海阔天空。<br />
27.擦桌子的时候要往自己的方向抹 。<br />
28.打电话接电话第一句话一定要是 喂，您好；挂电话的时候等别人先挂。<br />
29.一次不忠 百次不容。<br />
30.不随地吐痰扔东西，如果没有垃圾箱，就拎回家扔垃圾筒里。<br />
31.多看书对心灵有益,你会看到一个更广阔的世界 。<br />
32.是你去适应社会,不是社会来适应你。<br />
33.不要让别人知道自己的真实想法,要笑在人前笑, 要哭一个人躲起来哭。<br />
34.走路手不要插在口袋里。<br />
35.简单的事情复杂做，复杂的事情简单做 。<br />
36.机会只留给有准备的人，天上不会掉馅饼。<br />
37.不管什么条件下，仔细刷牙，特别是晚上 。<br />
38.早上一定要吃早餐，没有早餐喝杯水也一定要 。<br />
39.少说别人是非，把自己管牢 。<br />
40.你是无价之宝 。<br />
41.女生，和男孩子出去要自己买单 。<br />
42.要对自己的行为负责，不要怨天由人，在做之前要想想应不应该，出了事要学会自己解决 。<br />
43.要想人前显贵，必先人后受罪</p>
<h3  class="related_post_title">随机日志</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=1340" title="CSS查找匹配原理和简洁高效">CSS查找匹配原理和简洁高效</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1333" title="CSS清除浮动">CSS清除浮动</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1086" title="本命年真倒霉">本命年真倒霉</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=1313" title="jQuery性能优化">jQuery性能优化</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=315" title="XHTML模块化布局">XHTML模块化布局</a> (16)</li><li><a href="http://www.hemin.cn/blog/?p=1270" title="各种jquery实例效果">各种jquery实例效果</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=506" title="2007年韩国最感人的MV">2007年韩国最感人的MV</a> (2)</li><li><a href="http://www.hemin.cn/blog/?p=1354" title="tudou首页图片延迟加载">tudou首页图片延迟加载</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1167" title="40条优化php代码的小实例">40条优化php代码的小实例</a> (2)</li><li><a href="http://www.hemin.cn/blog/?p=270" title="CSS居中问题">CSS居中问题</a> (1)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1235</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关于一个布局的写法</title>
		<link>http://www.hemin.cn/blog/?p=1213</link>
		<comments>http://www.hemin.cn/blog/?p=1213#comments</comments>
		<pubDate>Mon, 31 May 2010 06:22:29 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[(x)Html/Css]]></category>
		<category><![CDATA[布局]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1213</guid>
		<description><![CDATA[关于一个布局的写法,看见蓝色里面讨论个火热.我就凑合的写下。 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34; /&#62; &#60;title&#62;无标题文档&#60;/title&#62; &#60;style type=&#34;text/css&#34;&#62; *{ padding:0; margin:0;} dd{margin:12px auto; overflow:hidden;zoom:1; width:350px;} img{ float:left; border:0; padding-right:10px;} h3{color:#3063BE;font-size:14px;font-weight:bold;line-height:1.6;} p{ float:left;line-height:1.6; font-size:12px;width:270px;} &#60;/style&#62; &#60;/head&#62; &#60;body&#62; &#60;dl&#62; &#60;dd&#62;&#60;a href=&#34;#&#34;&#62;&#60;img src=&#34;http://www.pingan.com/app_images/pingan/v20/pinganlicaizhuanqu/pic_08.jpg&#34; /&#62;&#60;/a&#62; &#60;h3&#62;免担保免抵押&#60;/h3&#62; &#60;p&#62;子女教育、出国进修、新屋装修缺钱？平安银行快速帮你解决燃眉之急！ 子女教育、出国进修、新屋装修缺钱？平安银行快速帮你解决燃眉之急！ &#60;/p&#62; &#60;/dd&#62; &#60;dd&#62;&#60;a href=&#34;#&#34;&#62;&#60;img src=&#34;http://www.pingan.com/app_images/pingan/v20/pinganlicaizhuanqu/pic_08.jpg&#34; /&#62;&#60;/a&#62; &#60;h3&#62;免担保免抵押&#60;/h3&#62; &#60;p&#62;子女教育、出国进修、新屋装修缺钱？平安银行快速帮你解决燃眉之急！ 子女教育、出国进修、新屋装修缺钱？平安银行快速帮你解决燃眉之急！ [...]]]></description>
			<content:encoded><![CDATA[<p>关于一个布局的写法,看见蓝色里面讨论个火热.我就凑合的写下。</p>
<p><a href="http://www.hemin.cn/blog/wp-content/uploads/2010/05/1231222222.jpg"><img class="size-full wp-image-1214 alignnone" title="1231222222" src="http://www.hemin.cn/blog/wp-content/uploads/2010/05/1231222222.jpg" alt="" width="302" height="121" /></a><br />
<span id="more-1213"></span></p>
<div class="runcode">
<p><textarea name="runcode" style="height:200px;width:720px;font-size:12px" class="runcode_text" id="runcode_hZIm90">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;无标题文档&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
*{ padding:0; margin:0;}
dd{margin:12px auto; overflow:hidden;zoom:1; width:350px;}
img{ float:left; border:0; padding-right:10px;}
h3{color:#3063BE;font-size:14px;font-weight:bold;line-height:1.6;}
p{ float:left;line-height:1.6; font-size:12px;width:270px;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;dl&gt;
  &lt;dd&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.pingan.com/app_images/pingan/v20/pinganlicaizhuanqu/pic_08.jpg&quot; /&gt;&lt;/a&gt;
    &lt;h3&gt;免担保免抵押&lt;/h3&gt;
    &lt;p&gt;子女教育、出国进修、新屋装修缺钱？平安银行快速帮你解决燃眉之急！ 子女教育、出国进修、新屋装修缺钱？平安银行快速帮你解决燃眉之急！ &lt;/p&gt;
  &lt;/dd&gt;
  &lt;dd&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.pingan.com/app_images/pingan/v20/pinganlicaizhuanqu/pic_08.jpg&quot; /&gt;&lt;/a&gt;
    &lt;h3&gt;免担保免抵押&lt;/h3&gt;
    &lt;p&gt;子女教育、出国进修、新屋装修缺钱？平安银行快速帮你解决燃眉之急！ 子女教育、出国进修、新屋装修缺钱？平安银行快速帮你解决燃眉之急！ &lt;/p&gt;
  &lt;/dd&gt;
  &lt;dd&gt;&lt;a href=&quot;#&quot;&gt;&lt;img src=&quot;http://www.pingan.com/app_images/pingan/v20/pinganlicaizhuanqu/pic_08.jpg&quot; /&gt;&lt;/a&gt;
    &lt;h3&gt;免担保免抵押&lt;/h3&gt;
    &lt;p&gt;子女教育、出国进修、新屋装修缺钱？平安银行快速帮你解决燃眉之急！ 子女教育、出国进修、新屋装修缺钱？平安银行快速帮你解决燃眉之急！ &lt;/p&gt;
  &lt;/dd&gt;
&lt;/dl&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_hZIm90');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_hZIm90');"/> <input type="button" value="另存代码" class="runcode_button" onclick="saveCode('runcode_hZIm90','runcode_hZIm90');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>本来打算用ul标签，因li需要加list-style:none;，就放弃了。<br />
如果超出题目的范围的话</p>
<div class="hl-surround">
<ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)">
<li class="hl-firstline"><span style="color: Olive;">&lt;</span><span style="color: Green;">dl</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">dd</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">img</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp;&nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">div</span><span style="color: Olive;">&gt;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">&lt;</span><span style="color: Green;">h3</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &lt;</span><span style="color: Green;">p</span><span style="color: Olive;">&gt;</span></li>
</ol>
</div>
<p>这样就可以防止以后的变动了吧。</p>
<h3  class="related_post_title">随机日志</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=190" title="天啊,我娶个老婆最少得10年">天啊,我娶个老婆最少得10年</a> (10)</li><li><a href="http://www.hemin.cn/blog/?p=1286" title="各种jQuery技巧">各种jQuery技巧</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1133" title="腾讯Q组内部考核题">腾讯Q组内部考核题</a> (12)</li><li><a href="http://www.hemin.cn/blog/?p=407" title="Web前端开发电子书 更新为2009.12.9">Web前端开发电子书 更新为2009.12.9</a> (35)</li><li><a href="http://www.hemin.cn/blog/?p=90" title="随写08年腾讯面试题(实习生)">随写08年腾讯面试题(实习生)</a> (17)</li><li><a href="http://www.hemin.cn/blog/?p=220" title="CSS优先权的计算">CSS优先权的计算</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=1154" title="互联网免费模式">互联网免费模式</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=761" title="五种实现等高方法">五种实现等高方法</a> (10)</li><li><a href="http://www.hemin.cn/blog/?p=1354" title="tudou首页图片延迟加载">tudou首页图片延迟加载</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=138" title="表格小知识">表格小知识</a> (0)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1213</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>前端工程师面试</title>
		<link>http://www.hemin.cn/blog/?p=1208</link>
		<comments>http://www.hemin.cn/blog/?p=1208#comments</comments>
		<pubDate>Sun, 30 May 2010 12:57:03 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[(x)Html/Css]]></category>
		<category><![CDATA[JS/JQuery]]></category>
		<category><![CDATA[面试题]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1208</guid>
		<description><![CDATA[一些前端工程师面试内容 1.Doctype? 严格模式与混杂模式-如何触发这两种模式，区分它们有何意义? 2：行内元素有哪些？块级元素有哪些？CSS的盒模型？ 3.CSS引入的方式有哪些? link和@import的区别是? 4.CSS选择符有哪些？哪些属性可以继承？优先级算法如何计算？内联和important哪个优先级高？ 5:前端页面有哪三层构成，分别是什么？作用是什么？ 6:css的基本语句构成是？ 8：你做的页面在哪些流览器测试过？这些浏览器的内核分别是什么?经常遇到的浏览器的兼容性有哪些？怎么会出现？解决方法是什么？ 9.如何居中一个浮动元素? 10.有没有关注HTML5和CSS3?如有请简单说一些您对它们的了解情况！ 11.你怎么来实现下面这个设计图,主要讲述思路 （效果图省略） 13:如果让你来制作一个访问量很高的大型网站，你会如何来管理所有CSS文件、JS与图片？ 14：你对前端界面工程师这个职位是怎么样理解的？它的前景会怎么样？ 相关文章：腾讯Q组内部考核题 (12)百度2010校园招聘前端开发笔试题 (6)08年阿里巴巴前端开发面试题 (6)面试题：纯CSS菜单和纯CSS选项卡 (1)随写08年腾讯面试题(实习生) (17)练习迅雷面试题 (19)]]></description>
			<content:encoded><![CDATA[<p>一些前端工程师面试内容<br />
1.Doctype? 严格模式与混杂模式-如何触发这两种模式，区分它们有何意义? </p>
<p>2：行内元素有哪些？块级元素有哪些？CSS的盒模型？</p>
<p>3.CSS引入的方式有哪些? link和@import的区别是?</p>
<p>4.CSS选择符有哪些？哪些属性可以继承？优先级算法如何计算？内联和important哪个优先级高？</p>
<p>5:前端页面有哪三层构成，分别是什么？作用是什么？</p>
<p>6:css的基本语句构成是？<br />
<span id="more-1208"></span><br />
8：你做的页面在哪些流览器测试过？这些浏览器的内核分别是什么?经常遇到的浏览器的兼容性有哪些？怎么会出现？解决方法是什么？</p>
<p>9.如何居中一个浮动元素?</p>
<p>10.有没有关注HTML5和CSS3?如有请简单说一些您对它们的了解情况！</p>
<p>11.你怎么来实现下面这个设计图,主要讲述思路 （效果图省略）</p>
<p>13:如果让你来制作一个访问量很高的大型网站，你会如何来管理所有CSS文件、JS与图片？</p>
<p>14：你对前端界面工程师这个职位是怎么样理解的？它的前景会怎么样？</p>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=1133" title="腾讯Q组内部考核题">腾讯Q组内部考核题</a> (12)</li><li><a href="http://www.hemin.cn/blog/?p=1104" title="百度2010校园招聘前端开发笔试题">百度2010校园招聘前端开发笔试题</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=1099" title="08年阿里巴巴前端开发面试题">08年阿里巴巴前端开发面试题</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=259" title="面试题：纯CSS菜单和纯CSS选项卡">面试题：纯CSS菜单和纯CSS选项卡</a> (1)</li><li><a href="http://www.hemin.cn/blog/?p=90" title="随写08年腾讯面试题(实习生)">随写08年腾讯面试题(实习生)</a> (17)</li><li><a href="http://www.hemin.cn/blog/?p=37" title="练习迅雷面试题">练习迅雷面试题</a> (19)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.hemin.cn/blog/?feed=rss2&amp;p=1208</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>10个javascript Frameworks 外连</title>
		<link>http://www.hemin.cn/blog/?p=1203</link>
		<comments>http://www.hemin.cn/blog/?p=1203#comments</comments>
		<pubDate>Sun, 30 May 2010 12:48:17 +0000</pubDate>
		<dc:creator>hemin</dc:creator>
				<category><![CDATA[JS/JQuery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[框架]]></category>

		<guid isPermaLink="false">http://www.hemin.cn/blog/?p=1203</guid>
		<description><![CDATA[google提供的10个javascript Frameworks 外连： jquery &#60;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&#62;&#60;/script&#62; jquery UI &#60;script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"&#62;&#60;/script&#62; Chrome Frame &#60;script src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1.0.2/CFInstall.min.js"&#62;&#60;/script&#62; swfobject &#60;script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"&#62;&#60;/script&#62; mootools &#60;script src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js"&#62;&#60;/script&#62; Yahoo! UI &#60;script src="http://ajax.googleapis.com/ajax/libs/yui/2.8.1/build/yuiloader/yuiloader-min.js"&#62;&#60;/script&#62; Prototype &#60;script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js"&#62;&#60;/script&#62; Ext.JS &#60;script src="http://ajax.googleapis.com/ajax/libs/ext-core/3.1.0/ext-core.js"&#62;&#60;/script&#62; Dojo &#60;script src="http://ajax.googleapis.com/ajax/libs/dojo/1.4.3/dojo/dojo.xd.js"&#62;&#60;/script&#62; Scriptaculous &#60;script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js"&#62;&#60;/script&#62; 相关文章：各种javascript实例效果 更新为2010.07.26 (4)javascript字符串反转 (0)物体碰撞反弹与圆周运动 (0)百度2010校园招聘前端开发笔试题 (6)08年阿里巴巴前端开发面试题 (6)我推荐的书籍 (0)CSS框架 (5)各种Javascript技巧 (0)JavaScript 快速组合算法 (0)入门JavaScript正则表达式 (0)]]></description>
			<content:encoded><![CDATA[<div id="blogDetailDiv">
<p>google提供的10个javascript Frameworks 外连：</p>
<h2>jquery</h2>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;</pre>
<h2>jquery UI</h2>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"&gt;&lt;/script&gt;</pre>
<h2>Chrome Frame</h2>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/chrome-frame/1.0.2/CFInstall.min.js"&gt;&lt;/script&gt;</pre>
<p><span id="more-1203"></span></p>
<h2>swfobject</h2>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"&gt;&lt;/script&gt;</pre>
<h2>mootools</h2>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js"&gt;&lt;/script&gt;</pre>
<h2>Yahoo! UI</h2>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/yui/2.8.1/build/yuiloader/yuiloader-min.js"&gt;&lt;/script&gt;</pre>
<h2>Prototype</h2>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js"&gt;&lt;/script&gt;</pre>
<h2>Ext.JS</h2>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/ext-core/3.1.0/ext-core.js"&gt;&lt;/script&gt;</pre>
<h2>Dojo</h2>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/dojo/1.4.3/dojo/dojo.xd.js"&gt;&lt;/script&gt;</pre>
<h2>Scriptaculous</h2>
<pre>&lt;script src="http://ajax.googleapis.com/ajax/libs/scriptaculous/1.8.3/scriptaculous.js"&gt;&lt;/script&gt;</pre>
</div>
<h3  class="related_post_title">相关文章：</h3><ul class="related_post"><li><a href="http://www.hemin.cn/blog/?p=341" title="各种javascript实例效果 更新为2010.07.26">各种javascript实例效果 更新为2010.07.26</a> (4)</li><li><a href="http://www.hemin.cn/blog/?p=1284" title="javascript字符串反转">javascript字符串反转</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1122" title="物体碰撞反弹与圆周运动">物体碰撞反弹与圆周运动</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1104" title="百度2010校园招聘前端开发笔试题">百度2010校园招聘前端开发笔试题</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=1099" title="08年阿里巴巴前端开发面试题">08年阿里巴巴前端开发面试题</a> (6)</li><li><a href="http://www.hemin.cn/blog/?p=1068" title="我推荐的书籍">我推荐的书籍</a> (0)</li><li><a href="http://www.hemin.cn/blog/?p=1037" title="CSS框架">CSS框架</a> (5)</li><li><a href="http://www.hemin.cn/blog/?p=945" title="各种Java