<?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>Life Studio &#187; jQuery</title>
	<atom:link href="http://wange.im/tag/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://wange.im</link>
	<description>My Life, My Studio...</description>
	<lastBuildDate>Fri, 20 Jan 2012 01:49:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>基于 jQuery 的图片/文字无缝滚动</title>
		<link>http://wange.im/marquee-scroll.html</link>
		<comments>http://wange.im/marquee-scroll.html#comments</comments>
		<pubDate>Tue, 20 Dec 2011 15:14:53 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[无缝滚动]]></category>

		<guid isPermaLink="false">http://wange.im/?p=5213</guid>
		<description><![CDATA[你知道 jQuery，你也知道图片滚动的效果，但是你知道啥叫无缝滚动不？无缝滚动，就是无缝的滚动！换句话说，无缝滚动就是，图片或者文字下一张下一张地滚动，当滚动到屁股的时候就看到头了，反过来，当滚动到头的时候又能看到屁股了。还是看 DEMO 吧，或许更好理解一些。如你所见，当作为一排图片展示的时候，无缝滚动可以让人有无尽的感觉，页面一下子就充实了。 因为我也不是刻意去写这个 jQuery 的无缝滚动，所以 JS 也没封装过，只提供了几个基本的参数作修改，只能仅作参考。 HTML 部分： &#60;div class=&#34;scroll_area&#34;&#62; &#160;&#160;&#160; &#60;div class=&#34;scroll_list&#34;&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;ul class=&#34;scroll_ul&#34;&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li&#62;1&#60;/li&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li&#62;2&#60;/li&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li&#62;3&#60;/li&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li&#62;4&#60;/li&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li&#62;5&#60;/li&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li&#62;6&#60;/li&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li&#62;7&#60;/li&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li&#62;8&#60;/li&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li&#62;9&#60;/li&#62; &#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/ul&#62; &#160;&#160;&#160; &#60;/div&#62; &#160;&#160;&#160; &#60;a id=&#34;prev&#34; class=&#34;btn_icon&#34; href=&#34;javascript:;&#34;&#62;上一个&#60;/a&#62; &#160;&#160;&#160; &#60;a id=&#34;next&#34; class=&#34;btn_icon&#34; href=&#34;javascript:;&#34;&#62;下一个&#60;/a&#62; &#60;/div&#62; jQuery 部分： $(function() [...]]]></description>
			<content:encoded><![CDATA[<p>你知道 jQuery，你也知道图片滚动的效果，但是你知道啥叫无缝滚动不？无缝滚动，就是无缝的滚动！换句话说，无缝滚动就是，图片或者文字下一张下一张地滚动，当滚动到屁股的时候就看到头了，反过来，当滚动到头的时候又能看到屁股了。还是看 <a title="jQuery 无缝滚动" href="http://wange.im/demo/marquee/">DEMO</a> 吧，或许更好理解一些。如你所见，当作为一排图片展示的时候，无缝滚动可以让人有无尽的感觉，页面一下子就充实了。</p>
<p>因为我也不是刻意去写这个 jQuery 的无缝滚动，所以 JS 也没封装过，只提供了几个基本的参数作修改，只能仅作参考。</p>
<p>HTML 部分：</p>
<div style='color: rgb(0, 0, 0); font-family: "Courier New","Consolas","Lucida Console";' class="source"> <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;div</span> <span style="color: rgb(255, 0, 0);">class=</span><span style="color: rgb(0, 0, 255);">&quot;scroll_area&quot;</span><span style="color: rgb(0, 0, 128); font-weight: bold;">&gt;</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;div</span> <span style="color: rgb(255, 0, 0);">class=</span><span style="color: rgb(0, 0, 255);">&quot;scroll_list&quot;</span><span style="color: rgb(0, 0, 128); font-weight: bold;">&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;ul</span> <span style="color: rgb(255, 0, 0);">class=</span><span style="color: rgb(0, 0, 255);">&quot;scroll_ul&quot;</span><span style="color: rgb(0, 0, 128); font-weight: bold;">&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;li&gt;</span>1<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/li&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;li&gt;</span>2<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/li&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;li&gt;</span>3<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/li&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;li&gt;</span>4<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/li&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;li&gt;</span>5<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/li&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;li&gt;</span>6<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/li&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;li&gt;</span>7<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/li&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;li&gt;</span>8<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/li&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;li&gt;</span>9<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/li&gt;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/ul&gt;</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/div&gt;</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;a</span> <span style="color: rgb(255, 0, 0);">id=</span><span style="color: rgb(0, 0, 255);">&quot;prev&quot;</span> <span style="color: rgb(255, 0, 0);">class=</span><span style="color: rgb(0, 0, 255);">&quot;btn_icon&quot;</span> <span style="color: rgb(255, 0, 0);">href=</span><span style="color: rgb(0, 0, 255);">&quot;javascript:;&quot;</span><span style="color: rgb(0, 0, 128); font-weight: bold;">&gt;</span>上一个<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/a&gt;</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;a</span> <span style="color: rgb(255, 0, 0);">id=</span><span style="color: rgb(0, 0, 255);">&quot;next&quot;</span> <span style="color: rgb(255, 0, 0);">class=</span><span style="color: rgb(0, 0, 255);">&quot;btn_icon&quot;</span> <span style="color: rgb(255, 0, 0);">href=</span><span style="color: rgb(0, 0, 255);">&quot;javascript:;&quot;</span><span style="color: rgb(0, 0, 128); font-weight: bold;">&gt;</span>下一个<span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/a&gt;</span><br /> <span style="color: rgb(0, 0, 128); font-weight: bold;">&lt;/div&gt;</span></div>
<p>jQuery 部分：</p>
<div style='color: rgb(0, 0, 0); font-family: "Courier New","Consolas","Lucida Console";' class="source"> <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//配置变量</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">config</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">showNum</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 255);">3</span><span style="color: rgb(0, 0, 0);">,</span>&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//设置滚动的显示个数</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">autoScroll</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">false</span><span style="color: rgb(0, 0, 0);">,</span>&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//是否自动滚动，默认为 false</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">autoScrollInterval</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 255);">3000</span>&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//自动滚动间隔，默认为 3000 毫秒，autoScroll = true 时才有效</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">scrollUlWidth</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul li&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">outerWidth</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">true</span><span style="color: rgb(0, 0, 0);">),</span>&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//单个 li 的宽度</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">scrollUlLeft</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 255);">0</span><span style="color: rgb(0, 0, 0);">,</span>&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//.scroll_ul 初使化时的 left 值为 0</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">prevAllow</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">true</span><span style="color: rgb(0, 0, 0);">,</span>&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//为了防止连续点击上一页按钮</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">nextAllow</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">true</span>;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//为了防止连续点击下一页按钮</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//计算父容量限宽</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_list&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">width</span>(<span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">showNum</span> <span style="color: rgb(0, 0, 0);">*</span> <span style="color: rgb(0, 0, 0);">scrollUlWidth</span>);</p>
<p> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//点击上一页</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#prev&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">click</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> (<span style="color: rgb(0, 0, 0);">prevAllow</span>) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">prevAllow</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">false</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">scrollUlLeft</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">scrollUlLeft</span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);">scrollUlWidth</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">css</span>(<span style="color: rgb(0, 0, 255);">&#39;left&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 0);">scrollUlLeft</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//复制最后一个 li 并插入到 ul 的最前面</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul li:last&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">clone</span><span style="color: rgb(0, 0, 0);">().</span><span style="color: rgb(0, 0, 0);">prependTo</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//删除最后一个 li</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul li:last&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">remove</span>();<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">animate</span><span style="color: rgb(0, 0, 0);">({</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">left</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 0);">scrollUlLeft</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">scrollUlWidth</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">},</span> <span style="color: rgb(0, 0, 255);">300</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">scrollUlLeft</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">parseInt</span>(<span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">css</span>(<span style="color: rgb(0, 0, 255);">&#39;left&#39;</span><span style="color: rgb(0, 0, 0);">),</span> <span style="color: rgb(0, 0, 255);">10</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">prevAllow</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">true</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">})</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">});</span><br /> &nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//点击下一页</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#next&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">click</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> (<span style="color: rgb(0, 0, 0);">nextAllow</span>) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">nextAllow</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">false</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">animate</span><span style="color: rgb(0, 0, 0);">({</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">left</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 0);">scrollUlLeft</span> <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 0);">scrollUlWidth</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">},</span> <span style="color: rgb(0, 0, 255);">300</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">scrollUlLeft</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">parseInt</span>(<span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">css</span>(<span style="color: rgb(0, 0, 255);">&#39;left&#39;</span><span style="color: rgb(0, 0, 0);">),</span> <span style="color: rgb(0, 0, 255);">10</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">scrollUlLeft</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">scrollUlLeft</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">scrollUlWidth</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">css</span>(<span style="color: rgb(0, 0, 255);">&#39;left&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 0);">scrollUlLeft</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//复制第一个 li 并插入到 ul 的最后面</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul li:first&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">clone</span><span style="color: rgb(0, 0, 0);">().</span><span style="color: rgb(0, 0, 0);">appendTo</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//删除第一个 li</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.scroll_ul li:first&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">remove</span>();<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">nextAllow</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">true</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">})</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">});</span><br /> &nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//自动滚动</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> (<span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">autoScroll</span>) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">setInterval</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#next&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">trigger</span>(<span style="color: rgb(0, 0, 255);">&#39;click&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">},</span> <span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">autoScrollInterval</span>)<br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> <span style="color: rgb(0, 0, 0);">})</span></div>
<p>基本原理和使用方法都写在注释里了，我也就不多作解释了。最后说一句，google、百度上搜一下就知道，已经有大把大把写好的横的竖的无缝的滚动，总有一款适合你，但是我觉得，只有自己亲自写的才最适合自己的需要，所以就有了以上代码。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/picture/" title="图片" rel="tag">图片</a>,<a href="http://wange.im/tag/marquee-scroll/" title="无缝滚动" rel="tag">无缝滚动</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-highslide-on-demand.html" rel="bookmark" title="jQuery 按需加载 HighSlide 效果">jQuery 按需加载 HighSlide 效果</a>        <div class="rl_date">2011年10月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadeto-effect-with-jquery.html" rel="bookmark" title="利用 JQuery 实现图片显隐特效">利用 JQuery 实现图片显隐特效</a>        <div class="rl_date">2010年04月8日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-slide-pic-show.html" rel="bookmark" title="JQuery 实现带滑动层的图片展示效果">JQuery 实现带滑动层的图片展示效果</a>        <div class="rl_date">2010年02月24日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/marquee-scroll.html/feed</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>jQuery 按需加载 HighSlide 效果</title>
		<link>http://wange.im/jquery-highslide-on-demand.html</link>
		<comments>http://wange.im/jquery-highslide-on-demand.html#comments</comments>
		<pubDate>Mon, 10 Oct 2011 14:09:48 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[HighSlide]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[图片]]></category>
		<category><![CDATA[轮播图]]></category>

		<guid isPermaLink="false">http://wange.im/?p=5132</guid>
		<description><![CDATA[从本文标题可知，这篇文章和上一篇的《jQuery 按需加载轮播图》有着说不清道不明的关系，是的，我就他瞄的和按需加载较上劲了，用 jQuery 来做 HighSlide 的插件已经有不少了，我再横插一脚就是为了这个按需加载，而且还要做到最精简最优化。做这个的理由和上一篇文章中提到的基本一样，第一，为了加载速度的大大提升；第二，为了满足 SEO 的需求。 相信大多数同学，包括我在内，用到的图片 HighSlide 效果都是用的 WordPress 的插件，或者引的 jQuery 的插件，但是这必竟不能完全满足我的需求，而且在我看来那些 JS 也太庞大了一些，还不如自己写一个。做了一个简单的 DEMO，大家可以看一下。 如果你会用 Firebug 这样的工具，就可以看到，页面中所有的图片，包括 DOM 节点，都是通过 JS 注入进来的，而且在初使化的时候只生成当前显示的五组图片，只有当用户点击下一张或者点击图片放大时，才会有新的图片和节点加载进来，同样，如果用户不点击，就不会去加载。这就大大节省了初使化需要加载的图片数量。 在 JS 没有压缩之前，也只有区区 6K 的大小，所以我相信这是大多数用户和站长都能够接受的，不过虽说只有 6K，也有近 200 行的代码，篇幅有限，我就不把具体的 JS 和 CSS 贴出来了，有需要的朋友可以直接下载我的 DEMO，DEMO 里的 JS 没有压缩，注释也都写的比较清楚。 最终效果和现在我用的差不多，但是代码却千差万别，细节决定成败，争取做好每一个细节！ 与 HighSlide,jQuery,图片,轮播图 相关的文章 基于 jQuery 的图片/文字无缝滚动 2011年12月20日 jQuery 按需加载轮播图 2011年09月26日 jQuery/JavaScript 实现的异步加载图片 2011年04月10日 利用 [...]]]></description>
			<content:encoded><![CDATA[<p>从本文标题可知，这篇文章和上一篇的《<a title="jQuery 按需加载轮播图" href="http://wange.im/jquery-slide-loaded-on-demand.html">jQuery 按需加载轮播图</a>》有着说不清道不明的关系，是的，我就他瞄的和<strong>按需加载</strong>较上劲了，用 jQuery 来做 HighSlide 的插件已经有不少了，我再横插一脚就是为了这个按需加载，而且还要做到最精简最优化。做这个的理由和上一篇文章中提到的基本一样，第一，为了加载速度的大大提升；第二，为了满足 SEO 的需求。</p>
<p>相信大多数同学，包括我在内，用到的图片 HighSlide 效果都是用的 WordPress 的插件，或者引的 jQuery 的插件，但是这必竟不能完全满足我的需求，而且在我看来那些 JS 也太庞大了一些，还不如自己写一个。做了一个简单的 <a title="jQuery 按需加载 HighSlide 效果" href="http://wange.im/demo/highslide/">DEMO</a>，大家可以看一下。</p>
<p>如果你会用 Firebug 这样的工具，就可以看到，页面中所有的图片，包括 DOM 节点，都是通过 JS 注入进来的，而且在初使化的时候只生成当前显示的五组图片，只有当用户点击下一张或者点击图片放大时，才会有新的图片和节点加载进来，同样，如果用户不点击，就不会去加载。这就大大节省了初使化需要加载的图片数量。</p>
<p>在 JS 没有压缩之前，也只有区区 6K 的大小，所以我相信这是大多数用户和站长都能够接受的，不过虽说只有 6K，也有近 200 行的代码，篇幅有限，我就不把具体的 JS 和 CSS 贴出来了，有需要的朋友可以直接下载我的 <a title="jQuery 按需加载 HighSlide 效果" href="http://wange.im/demo/highslide/">DEMO</a>，DEMO 里的 JS 没有压缩，注释也都写的比较清楚。</p>
<p>最终效果和现在我用的差不多，但是代码却千差万别，细节决定成败，争取做好每一个细节！</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/highslide/" title="HighSlide" rel="tag">HighSlide</a>,<a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/picture/" title="图片" rel="tag">图片</a>,<a href="http://wange.im/tag/slide/" title="轮播图" rel="tag">轮播图</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/marquee-scroll.html" rel="bookmark" title="基于 jQuery 的图片/文字无缝滚动">基于 jQuery 的图片/文字无缝滚动</a>        <div class="rl_date">2011年12月20日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-slide-loaded-on-demand.html" rel="bookmark" title="jQuery 按需加载轮播图">jQuery 按需加载轮播图</a>        <div class="rl_date">2011年09月26日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadeto-effect-with-jquery.html" rel="bookmark" title="利用 JQuery 实现图片显隐特效">利用 JQuery 实现图片显隐特效</a>        <div class="rl_date">2010年04月8日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/jquery-highslide-on-demand.html/feed</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>jQuery 按需加载轮播图</title>
		<link>http://wange.im/jquery-slide-loaded-on-demand.html</link>
		<comments>http://wange.im/jquery-slide-loaded-on-demand.html#comments</comments>
		<pubDate>Mon, 26 Sep 2011 12:47:02 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[轮播图]]></category>

		<guid isPermaLink="false">http://wange.im/?p=5126</guid>
		<description><![CDATA[引言 关于幻灯轮播图，想必大家都不陌生，尤其是基于 jQuery 的，插件、代码网上一搜一大堆，但是真正符合自己需求的几乎没有，所以我要打造一个符合自身需求，经得起广大网民考验的 jQuery 轮播图！ 思路 为什么说网上其他一些轮播图不符合我的要求？我的需求又是什么呢？ 现在网上可以找到的多数幻灯轮播图的 jQuery 插件的作法是，先把图片和链接的 HTML 写好，然后控制隐藏和显示来轮流展示当前的幻灯图片。但是对用户而言，我们始终只是看到当前的一张图片，那其他几张隐藏的图片为什么要事先加载进来呢？这不是费时费力吗？所以我的第一个需求是按需加载。 我们一般会把轮播图放在首页展示，但是首页的重点内容应该是最近更新的文章，至少我不认为图片展示功能需要被搜索引擎收录，所以我的第二个需求是符合  SEO。 实现 冲着以上两个需求，我做了一个 DEMO，这个 DEMO 和我现在的首页看起来效果基本一致，但实现的方法却天差地别。大家不妨看看这个 DEMO 的源代码，发现区别了吗？是的，在这个 DEMO 的 HTML 源代码中，你看不到任何的图片和相关信息，都由 JS 载入进来的，也就是说爬虫爬不到，而且是随着图片的切换，一张一张地载入当前的幻灯图片。 这里我就只分享一下我的 JS 写法，HTML 什么就请各位看源码吧，代码我就不一一细说了，注释也都写得很明白了。 $(function() { &#160;&#160;&#160; var WangeSlide = (function() { &#160;&#160;&#160;&#160;&#160;&#160;&#160; //配置 &#160;&#160;&#160;&#160;&#160;&#160;&#160; var config = { &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //轮播图尺寸 &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; width : 560, &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; height [...]]]></description>
			<content:encoded><![CDATA[<p><strong>引言</strong></p>
<p>关于幻灯轮播图，想必大家都不陌生，尤其是基于 jQuery 的，插件、代码网上一搜一大堆，但是真正符合自己需求的几乎没有，所以我要打造一个符合自身需求，经得起广大网民考验的 jQuery 轮播图！</p>
<p><strong>思路</strong></p>
<p>为什么说网上其他一些轮播图不符合我的要求？我的需求又是什么呢？</p>
<p>现在网上可以找到的多数幻灯轮播图的 jQuery 插件的作法是，先把图片和链接的 HTML 写好，然后控制隐藏和显示来轮流展示当前的幻灯图片。但是对用户而言，我们始终只是看到当前的一张图片，那其他几张隐藏的图片为什么要事先加载进来呢？这不是费时费力吗？所以我的第一个需求是<strong>按需加载</strong>。</p>
<p>我们一般会把轮播图放在首页展示，但是首页的重点内容应该是最近更新的文章，至少我不认为图片展示功能需要被搜索引擎收录，所以我的第二个需求是<strong>符合  SEO</strong>。</p>
<p><strong>实现</strong></p>
<p>冲着以上两个需求，我做了一个 <a title="jQuery 按需加载轮播图" href="http://wange.im/demo/slide-on-demand/">DEMO</a>，这个 DEMO 和我现在的首页看起来效果基本一致，但实现的方法却天差地别。大家不妨看看这个 <a title="jQuery 按需加载轮播图" href="http://wange.im/demo/slide-on-demand/">DEMO</a> 的源代码，发现区别了吗？是的，在这个 DEMO 的 HTML 源代码中，你看不到任何的图片和相关信息，都由 JS 载入进来的，也就是说爬虫爬不到，而且是随着图片的切换，一张一张地载入当前的幻灯图片。</p>
<p>这里我就只分享一下我的 JS 写法，HTML 什么就请各位看源码吧，代码我就不一一细说了，注释也都写得很明白了。</p>
<div style='color: rgb(0, 0, 0); font-family: "Courier New","Consolas","Lucida Console"; background-color: rgb(255, 255, 255);' class="source"> <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">WangeSlide</span> <span style="color: rgb(0, 0, 0);">=</span> (<span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//配置</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">config</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//轮播图尺寸</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">width</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 255);">560</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">height</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 255);">250</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//是否自动切换</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">autoSwitch</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">true</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//自动切换间隔时间（毫秒）</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">interval</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 255);">6000</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//轮播图图片路径</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">picPath</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 255);">&#39;http://wange.im/wp-content/themes/wange/images/slides/&#39;</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//轮播图图片信息：图片文件名 / 图片标题 / 图片指向链接</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">picInfo</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 0);">[</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 255);">&#39;1.jpg&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;全套服务，求包养！&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;http://wange.im/qiu-bao-yang.html&#39;</span><span style="color: rgb(0, 0, 0);">],</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 255);">&#39;2.jpg&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;2012年的冬天还会冷吗？&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;http://wange.im/winter-in-2012.html&#39;</span><span style="color: rgb(0, 0, 0);">],</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 255);">&#39;3.jpg&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;Wordpress 免插件版侧边栏读者墙&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;http://wange.im/readerwall-on-sidebar-without-plugins.html&#39;</span><span style="color: rgb(0, 0, 0);">],</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 255);">&#39;4.jpg&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;Wordpress 免插件实现运行代码框&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;http://wange.im/run-code-in-wordpress-without-plugins.html&#39;</span><span style="color: rgb(0, 0, 0);">]</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">]</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">};</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//获取图片信息</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">/**</span><br /> <span style="color: rgb(0, 136, 0); font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * @param index 图片所在的索引值</span><br /> <span style="color: rgb(0, 136, 0); font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; **/</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">getImgInfo</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>(<span style="color: rgb(0, 0, 0);">index</span>) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">imgSrc</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">picPath</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">picInfo</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">][</span><span style="color: rgb(0, 0, 255);">0</span><span style="color: rgb(0, 0, 0);">],</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">imgAlt</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">picInfo</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">][</span><span style="color: rgb(0, 0, 255);">1</span><span style="color: rgb(0, 0, 0);">],</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">imgUrl</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">picInfo</span><span style="color: rgb(0, 0, 0);">[</span><span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">][</span><span style="color: rgb(0, 0, 255);">2</span><span style="color: rgb(0, 0, 0);">],</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">imgId</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 255);">&#39;slide_&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> (<span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 255);">1</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">toString</span><span style="color: rgb(0, 0, 0);">(),</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">imgHtml</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 255);">&#39;&lt;li id=&quot;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">imgId</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;&quot;&gt;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 255);">&#39;&nbsp;&nbsp;&nbsp; &lt;a href=&quot;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">imgUrl</span> <span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 255);">&#39;&quot; title=&quot;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">imgAlt</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;&quot; target=&quot;_blank" rel="nofollow" class="pic"&gt;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 255);">&#39;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;img src=&quot;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">imgSrc</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;&quot; alt=&quot;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">imgAlt</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;&quot; class=&quot;slide_thumb" /&gt;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 255);">&#39;&nbsp;&nbsp;&nbsp; &lt;/a&gt;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 255);">&#39;&lt;/li&gt;&#39;</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">slideTextHtml</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 255);">&#39;&lt;a href=&quot;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">imgUrl</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;&quot; target=&quot;_blank" title="&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">imgAlt</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;&quot; rel=&quot;nofollow"&gt;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">imgAlt</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;&lt;/a&gt;&#39;</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">return</span> <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">imgAlt</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 0);">imgAlt</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">imgUrl</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 0);">imgUrl</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">imgHtml</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 0);">imgHtml</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">slideTextHtml</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 0);">slideTextHtml</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">};</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//图片完全加载后缓慢加载显示</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">fadeInImg</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>(<span style="color: rgb(0, 0, 0);">el</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 0);">speed</span>) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">el</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">load</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">this</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">fadeIn</span>(<span style="color: rgb(0, 0, 0);">speed</span>)<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">});</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">};</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//图片切换</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">/**</span><br /> <span style="color: rgb(0, 136, 0); font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * @param index 图片所在的索引值</span><br /> <span style="color: rgb(0, 136, 0); font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * @param triggerCurEl 当前触发节点元素</span><br /> <span style="color: rgb(0, 136, 0); font-style: italic;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; **/</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">imgSwitch</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>(<span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 0);">triggerCurEl</span>) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">slideId</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 255);">&#39;slide_&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> (<span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 255);">1</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">toString</span><span style="color: rgb(0, 0, 0);">(),</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">slideIdEl</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">document</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">getElementById</span>(<span style="color: rgb(0, 0, 0);">slideId</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> (<span style="color: rgb(0, 0, 0);">slideIdEl</span>) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//如果已有对应的元素，则显示已有元素</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">panelLi</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#panel ul li&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;#slide&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">panelLi</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">fadeOut</span>(<span style="color: rgb(0, 0, 255);">&#39;slow&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 0);">slideIdEl</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">fadeIn</span>(<span style="color: rgb(0, 0, 255);">&#39;slow&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">else</span> <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//如果还没有对应的元素，则注入元素</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 0);">getImgInfo</span>(<span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">imgHtml</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">appendTo</span>(<span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#panel ul&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;#slide&#39;</span>));<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//载入显示图片</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">fadeInImg</span>(<span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.slide_thumb&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 0);">slideIdEl</span><span style="color: rgb(0, 0, 0);">),</span> <span style="color: rgb(0, 0, 255);">&#39;slow&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//获取图片的 alt 作为显示信息</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#slide_text&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">html</span>(<span style="color: rgb(0, 0, 0);">getImgInfo</span>(<span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">slideTextHtml</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//当前状态 cur</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#trigger ul li&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;#slide&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">removeClass</span>(<span style="color: rgb(0, 0, 255);">&#39;cur&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">triggerCurEl</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">addClass</span>(<span style="color: rgb(0, 0, 255);">&#39;cur&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">};</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//轮播图</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">slide</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//设置轮播图尺寸</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#slide&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">css</span><span style="color: rgb(0, 0, 0);">({</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 255);">&#39;width&#39;</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">width</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;px&#39;</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 255);">&#39;height&#39;</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">height</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;px&#39;</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">});</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//初使化轮播图，只加载第一张图片信息</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#panel ul&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;#slide&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">html</span>(<span style="color: rgb(0, 0, 0);">getImgInfo</span>(<span style="color: rgb(0, 0, 255);">0</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">imgHtml</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//载入显示图片</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">fadeInImg</span>(<span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.slide_thumb&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;#slide_1&#39;</span><span style="color: rgb(0, 0, 0);">),</span> <span style="color: rgb(0, 0, 255);">500</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//注入背景层 + 触发器容器 + 轮播图文字容器</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">slideBg</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 255);">&#39;&lt;div id=&quot;slide_bg&quot;&gt;&lt;/div&gt;&#39;</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">trigger</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 255);">&#39;&lt;div id=&quot;trigger&quot;&gt;&lt;/div&gt;&#39;</span><span style="color: rgb(0, 0, 0);">,</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">slideText</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 255);">&#39;&lt;div id=&quot;slide_text&quot;&gt;&lt;/div&gt;&#39;</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#panel&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">after</span>(<span style="color: rgb(0, 0, 0);">slideBg</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">trigger</span> <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 0);">slideText</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//获取图片的 alt 作为显示信息</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#slide_text&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">html</span>(<span style="color: rgb(0, 0, 0);">getImgInfo</span>(<span style="color: rgb(0, 0, 255);">0</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">slideTextHtml</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//注入触发节点</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">triggerUl</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;&lt;ul&gt;&lt;/ul&gt;&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">triggerUl</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">appendTo</span>(<span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#trigger&#39;</span>));<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">for</span> (<span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">i</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 255);">0</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 0);">j</span><span style="color: rgb(0, 0, 0);">=</span><span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">picInfo</span>; <span style="color: rgb(0, 0, 0);">i</span><span style="color: rgb(0, 0, 0);">&lt;</span><span style="color: rgb(0, 0, 0);">j</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">length</span>; <span style="color: rgb(0, 0, 0);">i</span><span style="color: rgb(0, 0, 0);">++</span>) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;&lt;li&gt;&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> (<span style="color: rgb(0, 0, 0);">i</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 255);">1</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">toString</span>() <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;&lt;/li&gt;&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">appendTo</span>(<span style="color: rgb(0, 0, 0);">triggerUl</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//当前状态 cur</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#trigger ul li:first&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">addClass</span>(<span style="color: rgb(0, 0, 255);">&#39;cur&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//点击触发节点</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">triggerLi</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#trigger ul li&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;#slide&#39;</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">triggerLi</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">click</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">index</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">triggerLi</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">index</span>(<span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">this</span>));<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">imgSwitch</span>(<span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">this</span>));<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">});</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//鼠标悬停时，停止切换</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">goSwitch</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">true</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#slide&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">hover</span>(<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><span style="color: rgb(0, 0, 0);">goSwitch</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">false</span><span style="color: rgb(0, 0, 0);">},</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><span style="color: rgb(0, 0, 0);">goSwitch</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">true</span><span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; );<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//自动切换</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> (<span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">autoSwitch</span>) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">setInterval</span>(<span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> (<span style="color: rgb(0, 0, 0);">goSwitch</span>) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//判断当前cur所在的索引值</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">var</span> <span style="color: rgb(0, 0, 0);">index</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">parseInt</span>(<span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;.cur&#39;</span><span style="color: rgb(0, 0, 0);">,</span> <span style="color: rgb(0, 0, 255);">&#39;#trigger&#39;</span><span style="color: rgb(0, 0, 0);">).</span><span style="color: rgb(0, 0, 0);">text</span>()) <span style="color: rgb(0, 0, 0);">-</span> <span style="color: rgb(0, 0, 255);">1</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">if</span> (<span style="color: rgb(0, 0, 0);">index</span> <span style="color: rgb(0, 0, 0);">&gt;</span> (<span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">picInfo</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">length</span><span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 255);">2</span>)) <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">index</span> <span style="color: rgb(0, 0, 0);">=</span> <span style="color: rgb(0, 0, 0);">-</span><span style="color: rgb(0, 0, 255);">1</span>;<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">imgSwitch</span>((<span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 255);">1</span><span style="color: rgb(0, 0, 0);">),</span> <span style="color: rgb(0, 0, 0);">$</span>(<span style="color: rgb(0, 0, 255);">&#39;#trigger ul li:eq(&#39;</span> <span style="color: rgb(0, 0, 0);">+</span> (<span style="color: rgb(0, 0, 0);">index</span><span style="color: rgb(0, 0, 0);">+</span><span style="color: rgb(0, 0, 255);">1</span>) <span style="color: rgb(0, 0, 0);">+</span> <span style="color: rgb(0, 0, 255);">&#39;)&#39;</span>));<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">},</span> <span style="color: rgb(0, 0, 0);">config</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">interval</span>);<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">};</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 128); font-weight: bold;">return</span> <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 136, 0); font-style: italic;">//初使化</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">init</span> <span style="color: rgb(0, 0, 0);">:</span> <span style="color: rgb(0, 0, 128); font-weight: bold;">function</span>() <span style="color: rgb(0, 0, 0);">{</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">slide</span>();<br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">}</span><br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">})();</span><br /> &nbsp;&nbsp;&nbsp; <br /> &nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 0);">WangeSlide</span><span style="color: rgb(0, 0, 0);">.</span><span style="color: rgb(0, 0, 0);">init</span>();<br /> <span style="color: rgb(0, 0, 0);">})</span></div>
<p><strong>优势</strong></p>
<p>同样的效果，只是实现方法不同？会不会很蛋疼？这有什么优势呢？</p>
<p>举个例子来说，优化前，假设首页切换的幻灯图片有5张，平均每张图片20K，也就是说你的首页至少要加载100K的图片，而这100K的图片你能保证每个用户都会去看吗？如果用户不看，岂不是白白浪费了这100K的载入速度？</p>
<p>优化后，在首页初次载入的时候，仅需加载一张1K左右的，甚至是可有可无的 loading 图片，当用户点击下一张或者达到定时器的设置时才会去加载下一张图片，大大节省了载入的时间。1K？100K？你懂的。</p>
<p>另外，用 JS 载入所需的图片还有一个好处，就是在一些不支持 JS 的手机浏览器上，载入 100K 的图片对于无法切换的轮播图而言，是一个极大的累赘，而且也会大大降低用户体验。</p>
<p>好了，大家各取所需吧，我也只是提供了一个思路，如果有更好的实现方法欢迎与我交流。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/slide/" title="轮播图" rel="tag">轮播图</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-highslide-on-demand.html" rel="bookmark" title="jQuery 按需加载 HighSlide 效果">jQuery 按需加载 HighSlide 效果</a>        <div class="rl_date">2011年10月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/marquee-scroll.html" rel="bookmark" title="基于 jQuery 的图片/文字无缝滚动">基于 jQuery 的图片/文字无缝滚动</a>        <div class="rl_date">2011年12月20日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/ajax-get-in-jquery.html" rel="bookmark" title="用 jQuery 实现异步跨域请求">用 jQuery 实现异步跨域请求</a>        <div class="rl_date">2011年09月6日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-dialog-layer.html" rel="bookmark" title="jQuery 精简版弹出对话框层">jQuery 精简版弹出对话框层</a>        <div class="rl_date">2011年05月11日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/jquery-slide-loaded-on-demand.html/feed</wfw:commentRss>
		<slash:comments>65</slash:comments>
		</item>
		<item>
		<title>用 jQuery 实现异步跨域请求</title>
		<link>http://wange.im/ajax-get-in-jquery.html</link>
		<comments>http://wange.im/ajax-get-in-jquery.html#comments</comments>
		<pubDate>Tue, 06 Sep 2011 15:36:52 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://wange.im/?p=5091</guid>
		<description><![CDATA[最近在项目中有这样一个需求，需要异步跨域发送请求，而且是要跨大域，也就是在 a.com 请求 b.com 上的数据，我还从来没有用 YUI 去处理过这样一个异步跨域的请求，询问了做过同类需求的同事，才知道可以用 YUI 的 YAHOO.util.Get.script 方法，用 JSONP 格式来调用跨域的数据，而且兼容所有浏览器。 这个思路很不错，但是用 YUI 的童鞋毕竟是少数，我想 jQuery 应该也有类似的方法来处理异步跨域请求，果然，让我找到了 jQuery 的 getScript 方法，和 YUI 的 YAHOO.util.Get.script  有异曲同工之妙。就做了一个简单的 DEMO。 首先，先定义好最终要调用的数据格式： window.demo = { "txt" : "Hello World" } 这就是所谓的 JSONP，把数据以 JSON 的格式保存在一个对象中，方便我们之后去引用这个对象。 然后，我们就可以用 getScript 的方法去异步加载刚才保存的 JS，并处理返回结果，方法如下： var url = 'http://hnxl2a.bay.livefilestore.com/y1ppSRzo-oh5zvQRz1vRRA7DycnwtWX5Lch33sFAaHAJz3a3EC3QuZQJ0wb88oPhxRdUTRrM4JwFCRtlyqzyjMP7w/demo.js'; var success = function() { alert(window.demo.txt) }; [...]]]></description>
			<content:encoded><![CDATA[<p>最近在项目中有这样一个需求，需要异步跨域发送请求，而且是要跨大域，也就是在 a.com 请求 b.com 上的数据，我还从来没有用 YUI 去处理过这样一个异步跨域的请求，询问了做过同类需求的同事，才知道可以用 YUI 的 YAHOO.util.Get.script 方法，用 JSONP 格式来调用跨域的数据，而且兼容所有浏览器。</p>
<p>这个思路很不错，但是用 YUI 的童鞋毕竟是少数，我想 jQuery 应该也有类似的方法来处理异步跨域请求，果然，让我找到了 jQuery 的 getScript 方法，和 YUI 的 YAHOO.util.Get.script  有异曲同工之妙。就做了一个简单的 DEMO。</p>
<p>首先，先定义好最终要调用的数据格式：</p>
<div class="source" style="color: #000000; font-family: 'Courier New','Consolas','Lucida Console';"><span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">demo</span> <span style="color: #000000;">=</span> <span style="color: #000000;">{</span><br />
<span style="color: #0000ff;">"txt"</span> <span style="color: #000000;">:</span> <span style="color: #0000ff;">"Hello World"</span><br />
<span style="color: #000000;">}</span></div>
<p>这就是所谓的 JSONP，把数据以 JSON 的格式保存在一个对象中，方便我们之后去引用这个对象。</p>
<p>然后，我们就可以用 getScript 的方法去异步加载刚才保存的 JS，并处理返回结果，方法如下：</p>
<div class="source" style="color: #000000; font-family: 'Courier New','Consolas','Lucida Console';"><span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">url</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">'http://hnxl2a.bay.livefilestore.com/y1ppSRzo-oh5zvQRz1vRRA7DycnwtWX5Lch33sFAaHAJz3a3EC3QuZQJ0wb88oPhxRdUTRrM4JwFCRtlyqzyjMP7w/demo.js'</span>;<br />
<span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">success</span> <span style="color: #000000;">=</span> <span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
<span style="color: #000000;">alert</span>(<span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">demo</span><span style="color: #000000;">.</span><span style="color: #000000;">txt</span>)<br />
<span style="color: #000000;">};</span><br />
<span style="color: #000000;">$</span><span style="color: #000000;">.</span><span style="color: #000000;">getScript</span>(<span style="color: #000000;">url</span><span style="color: #000000;">,</span> <span style="color: #000000;">success</span>);</div>
<p>保存以上两个文件，在本地运行就能看到效果，当然，不要忘记加载 jQuery。</p>
<p>后记：</p>
<p>1、写习惯了原生的 JS，难得记录一下 jQuery，还真有点不习惯。</p>
<p>2、已经有童鞋再三催促我更新，再不写些东西，自己都觉得不好意思。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/ajax/" title="AJAX" rel="tag">AJAX</a>,<a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/html5-innershiv-translated-doc.html" rel="bookmark" title="HTML5 innerShiv 翻译文档">HTML5 innerShiv 翻译文档</a>        <div class="rl_date">2011年03月11日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/marquee-scroll.html" rel="bookmark" title="基于 jQuery 的图片/文字无缝滚动">基于 jQuery 的图片/文字无缝滚动</a>        <div class="rl_date">2011年12月20日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-highslide-on-demand.html" rel="bookmark" title="jQuery 按需加载 HighSlide 效果">jQuery 按需加载 HighSlide 效果</a>        <div class="rl_date">2011年10月10日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/ajax-get-in-jquery.html/feed</wfw:commentRss>
		<slash:comments>83</slash:comments>
		</item>
		<item>
		<title>jQuery 精简版弹出对话框层</title>
		<link>http://wange.im/jquery-dialog-layer.html</link>
		<comments>http://wange.im/jquery-dialog-layer.html#comments</comments>
		<pubDate>Wed, 11 May 2011 13:47:24 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4839</guid>
		<description><![CDATA[弹出对话框在一个网站中是相对比较常见的功能，无论是确认信息还是注册申请，都可能会用到弹出层。用 JS 来实现这样的弹出对话框效果是再合适不过的了，就 jQuery 而言，就有很多高手们开发好的弹出层插件，甚至连 jQuery 官方也有提供 Dialog UI 组件。 之前写过一些弹出层的效果，也都是借助于别人开发好的 jQuery 插件，这些插件的优点是参数多、功能全、方便调用，但是不可避免地会导致插件脚本过于庞大，很多功能基本用不到，感谢任平生童鞋一语惊醒梦中人，其实弹出的对话框层用 jQuery 来实现是相当简单的，简单到只需要两句 JS，一句是弹出，另一句就是关闭。省去了很多不必要的冗余的功能和 JS 代码。 先来看一下 DEMO，再来看一下代码有多简单： 1、首先是 HTML 部分： &#60;input type="submit" id="layerBtn" value="点我点我快点我！！！" /&#62; &#60;!-- S 弹出层 --&#62; &#60;div id="layer"&#62;     &#60;p&#62;我弹出来了~&#60;/p&#62;     &#60;p&#62;我弹出来了~&#60;/p&#62;     &#60;p&#62;我弹出来了~&#60;/p&#62;     &#60;p&#62;我弹出来了~&#60;/p&#62;     &#60;p&#62;我弹出来了~&#60;/p&#62;     &#60;p&#62;我弹出来了~&#60;/p&#62;     &#60;p&#62;我弹出来了~&#60;/p&#62;     &#60;p&#62;我弹出来了~&#60;/p&#62;     &#60;a href="javascript:void(0)" title="关闭" id="close"&#62;X&#60;/a&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>弹出对话框在一个网站中是相对比较常见的功能，无论是确认信息还是注册申请，都可能会用到弹出层。用 JS 来实现这样的弹出对话框效果是再合适不过的了，就 jQuery 而言，就有很多高手们开发好的弹出层插件，甚至连 jQuery 官方也有提供 Dialog UI 组件。</p>
<p>之前写过一些弹出层的效果，也都是借助于别人开发好的 jQuery 插件，这些插件的优点是参数多、功能全、方便调用，但是不可避免地会导致插件脚本过于庞大，很多功能基本用不到，感谢<a title="任平生" href="http://rpsh.net/" target="_blank">任平生</a>童鞋一语惊醒梦中人，其实弹出的对话框层用 jQuery 来实现是相当简单的，简单到只需要两句 JS，一句是弹出，另一句就是关闭。省去了很多不必要的冗余的功能和 JS 代码。</p>
<p>先来看一下 <a title="jQuery 精简版弹出对话框层" href="http://wange.im/demo/layer/">DEMO</a>，再来看一下代码有多简单：</p>
<p>1、首先是 HTML 部分：</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"submit"</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"layerBtn"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"点我点我快点我！！！"</span> <span style="color: #000080; font-weight: bold;">/&gt;</span><br />
<span style="font-style: italic; color: #008800;">&lt;!-- S 弹出层 --&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"layer"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">我弹出来了~</span><span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">我弹出来了~</span><span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">我弹出来了~</span><span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">我弹出来了~</span><span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">我弹出来了~</span><span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">我弹出来了~</span><span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">我弹出来了~</span><span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;p&gt;</span><span style="color: #000000;">我弹出来了~</span><span style="color: #000080; font-weight: bold;">&lt;/p&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;a</span> <span style="color: #ff0000;">href=</span><span style="color: #0000ff;">"javascript:void(0)"</span> <span style="color: #ff0000;">title=</span><span style="color: #0000ff;">"关闭"</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"close"</span><span style="color: #000080; font-weight: bold;">&gt;</span><span style="color: #000000;">X</span><span style="color: #000080; font-weight: bold;">&lt;/a&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span><br />
<span style="font-style: italic; color: #008800;">&lt;!-- E 弹出层 --&gt;</span></div>
<p>2、然后是 CSS 部分：</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000000;">#layer</span><span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">width</span><span style="color: #000000;">:</span><span style="color: #0000ff;">600px</span>;<br />
    <span style="color: #000080; font-weight: bold;">height</span><span style="color: #000000;">:</span><span style="color: #0000ff;">300px</span>;<br />
    <span style="color: #000080; font-weight: bold;">background</span><span style="color: #000000;">:</span><span style="color: #0000ff;">#ccc</span>;<br />
    <span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">:</span><span style="color: #0000ff;">1px</span> <span style="color: #000080; font-weight: bold;">solid</span> <span style="color: #0000ff;">#aaa</span>;<br />
    <span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">fixed</span>;<br />
    <span style="background-color: #e3d2d2; color: #a61717;">_</span><span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">absolute</span>;    <span style="font-style: italic; color: #008800;">/* 勉强应付 IE6 */</span><br />
    <span style="color: #000080; font-weight: bold;">top</span><span style="color: #000000;">:</span><span style="color: #0000ff;">50%</span>;<br />
    <span style="color: #000080; font-weight: bold;">right</span><span style="color: #000000;">:</span><span style="color: #0000ff;">50%</span>;<br />
    <span style="color: #000080; font-weight: bold;">margin</span><span style="color: #000000;">:-</span><span style="color: #0000ff;">150px</span> <span style="color: #0000ff;">-300px</span> <span style="color: #0000ff;">0</span> <span style="color: #0000ff;">0</span>;<br />
    <span style="color: #000080; font-weight: bold;">display</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">none</span>;    <span style="font-style: italic; color: #008800;">/* 默认不显示 */</span><br />
<span style="color: #000000;">}</span><br />
<span style="color: #000000;">#close</span><span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">absolute</span>;<br />
    <span style="color: #000080; font-weight: bold;">top</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span>;<br />
    <span style="color: #000080; font-weight: bold;">right</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span>;<br />
    <span style="color: #000080; font-weight: bold;">font</span><span style="color: #000000;">:</span><span style="color: #0000ff;">20px</span><span style="color: #000000;">/</span><span style="color: #0000ff;">1</span> <span style="color: #000000;">Arial</span>;<br />
    <span style="color: #000080; font-weight: bold;">text-decoration</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">none</span>;<br />
<span style="color: #000000;">}</span></div>
<p>因为我们一般要求弹出层相对于浏览器窗口垂直水平居中，而且可以跟随滚动条下拉而下移，所以我这里用了 position:fixed; 但是 IE6 总是比较杯具，偏偏不支持这么一个 CSS，无奈我用了 position:absolute; 来对付 IE6，不过这也只能勉强解决这一 bug，因为 position:absolute 只能把弹出层固定在第一屏的垂直居中位置，而无法随滚动条下移，具体如何解决 fixed 这个 IE6 的 bug 在这里就不多费口舌了。</p>
<p>3、JS 部分，当然必需先加载 jQuery：</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #000000;">document</span><span style="color: #000000;">).</span><span style="color: #000000;">ready</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#layerBtn'</span><span style="color: #000000;">).</span><span style="color: #000000;">click</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#layer'</span><span style="color: #000000;">).</span><span style="color: #000000;">fadeIn</span><span style="color: #000000;">();});</span>    <span style="font-style: italic; color: #008800;">//弹出层</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#close'</span><span style="color: #000000;">).</span><span style="color: #000000;">click</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#layer'</span><span style="color: #000000;">).</span><span style="color: #000000;">fadeOut</span><span style="color: #000000;">();});</span>    <span style="font-style: italic; color: #008800;">//关闭层</span><br />
<span style="color: #000000;">});</span></div>
<p>好了，就是这样，算是一个超精简的弹出层效果吧，其中去掉了拖动效果和定时关闭等我认为不需要的代码，因为我需要的网站上只有一个弹出对话框，也没有考虑扩展性什么的，能省则省吧，管用就行，希望也能对你有用。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/marquee-scroll.html" rel="bookmark" title="基于 jQuery 的图片/文字无缝滚动">基于 jQuery 的图片/文字无缝滚动</a>        <div class="rl_date">2011年12月20日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-highslide-on-demand.html" rel="bookmark" title="jQuery 按需加载 HighSlide 效果">jQuery 按需加载 HighSlide 效果</a>        <div class="rl_date">2011年10月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-slide-loaded-on-demand.html" rel="bookmark" title="jQuery 按需加载轮播图">jQuery 按需加载轮播图</a>        <div class="rl_date">2011年09月26日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/ajax-get-in-jquery.html" rel="bookmark" title="用 jQuery 实现异步跨域请求">用 jQuery 实现异步跨域请求</a>        <div class="rl_date">2011年09月6日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/jquery-dialog-layer.html/feed</wfw:commentRss>
		<slash:comments>106</slash:comments>
		</item>
		<item>
		<title>jQuery 让滑动门滑动起来</title>
		<link>http://wange.im/jquery-sliding-doors.html</link>
		<comments>http://wange.im/jquery-sliding-doors.html#comments</comments>
		<pubDate>Mon, 25 Apr 2011 13:54:53 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4801</guid>
		<description><![CDATA[是不是已经看厌了单一的 Tab 切换选项卡呢？你用的滑动门效果真的能“滑动”吗？会滑动的滑动门是个神马样子呢？看偶滴首页吧，幻灯轮播右侧的“新鲜的、欢迎的、热评的”那一个模块，底下的箭头会随着鼠标的移动左右滑动，上面的内容也会跟着切换，这就是本文要介绍的 jQuery 让滑动门滑动起来。 先看一个我精简出来的 DEMO。然后再来分解一下： 一、首先还是 HTML 部分： &#60;!-- S 内容区域 --&#62;&#60;div id=&#34;tab&#34;&#62;&#160;&#160;&#160; &#60;div id=&#34;tabContentA&#34;&#62;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;p&#62;tabContentA&#60;/p&#62;&#160;&#160;&#160; &#60;/div&#62;&#160;&#160;&#160; &#60;div id=&#34;tabContentB&#34;&#62;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;p&#62;tabContentB&#60;/p&#62;&#160;&#160;&#160; &#60;/div&#62;&#160;&#160;&#160; &#60;div id=&#34;tabContentC&#34;&#62;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;p&#62;tabContentC&#60;/p&#62;&#160;&#160;&#160; &#60;/div&#62;&#60;/div&#62;&#60;!-- E 内容区域 --&#62;&#60;!-- S 滑块区域 --&#62;&#60;div id=&#34;switcher&#34;&#62;&#160;&#160;&#160; &#60;ul&#62;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li id=&#34;switcherA&#34;&#62;switcherA&#60;/li&#62;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li id=&#34;switcherB&#34;&#62;switcherB&#60;/li&#62;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;li id=&#34;switcherC&#34;&#62;switcherC&#60;/li&#62;&#160;&#160;&#160; &#60;/ul&#62;&#160;&#160;&#160; &#60;span&#62;&#60;!-- 跟随箭头 --&#62;&#60;/span&#62;&#60;/div&#62;&#60;!-- E 滑块区域 --&#62; 二、然后是 CSS 部分： *{margin:0;padding:0;}#tab{height:180px;padding:10px 20px;overflow:hidden;position:relative;}#tabContentB,#tabContentC{display:none;}/* 非首块内容区域默认不显示 */#tab [...]]]></description>
			<content:encoded><![CDATA[<p>是不是已经看厌了单一的 Tab 切换选项卡呢？你用的滑动门效果真的能“滑动”吗？会滑动的滑动门是个神马样子呢？看偶滴首页吧，幻灯轮播右侧的“新鲜的、欢迎的、热评的”那一个模块，底下的箭头会随着鼠标的移动左右滑动，上面的内容也会跟着切换，这就是本文要介绍的 jQuery 让滑动门滑动起来。</p>
<p>先看一个我精简出来的 <a title="jQuery 让滑动门滑动起来" href="http://wange.im/demo/sliding-doors/index.html">DEMO</a>。然后再来分解一下：</p>
<p>一、首先还是 HTML 部分：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Consolas', 'Lucida Console'; COLOR: #000000" class=source jQuery1303738797906="14"><SPAN style="FONT-STYLE: italic; COLOR: #008800">&lt;!-- S 内容区域 --&gt;</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;div</SPAN> <SPAN style="COLOR: #ff0000">id=</SPAN><SPAN style="COLOR: #0000ff">&quot;tab&quot;</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;div</SPAN> <SPAN style="COLOR: #ff0000">id=</SPAN><SPAN style="COLOR: #0000ff">&quot;tabContentA&quot;</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;p&gt;</SPAN><SPAN style="COLOR: #000000">tabContentA</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/p&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/div&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;div</SPAN> <SPAN style="COLOR: #ff0000">id=</SPAN><SPAN style="COLOR: #0000ff">&quot;tabContentB&quot;</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;p&gt;</SPAN><SPAN style="COLOR: #000000">tabContentB</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/p&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/div&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;div</SPAN> <SPAN style="COLOR: #ff0000">id=</SPAN><SPAN style="COLOR: #0000ff">&quot;tabContentC&quot;</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;p&gt;</SPAN><SPAN style="COLOR: #000000">tabContentC</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/p&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/div&gt;</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/div&gt;</SPAN><BR><SPAN style="FONT-STYLE: italic; COLOR: #008800">&lt;!-- E 内容区域 --&gt;</SPAN><BR><SPAN style="FONT-STYLE: italic; COLOR: #008800">&lt;!-- S 滑块区域 --&gt;</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;div</SPAN> <SPAN style="COLOR: #ff0000">id=</SPAN><SPAN style="COLOR: #0000ff">&quot;switcher&quot;</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;ul&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;li</SPAN> <SPAN style="COLOR: #ff0000">id=</SPAN><SPAN style="COLOR: #0000ff">&quot;switcherA&quot;</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&gt;</SPAN><SPAN style="COLOR: #000000">switcherA</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/li&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;li</SPAN> <SPAN style="COLOR: #ff0000">id=</SPAN><SPAN style="COLOR: #0000ff">&quot;switcherB&quot;</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&gt;</SPAN><SPAN style="COLOR: #000000">switcherB</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/li&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;li</SPAN> <SPAN style="COLOR: #ff0000">id=</SPAN><SPAN style="COLOR: #0000ff">&quot;switcherC&quot;</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&gt;</SPAN><SPAN style="COLOR: #000000">switcherC</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/li&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/ul&gt;</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;span&gt;</SPAN><SPAN style="FONT-STYLE: italic; COLOR: #008800">&lt;!-- 跟随箭头 --&gt;</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/span&gt;</SPAN><BR><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">&lt;/div&gt;</SPAN><BR><SPAN style="FONT-STYLE: italic; COLOR: #008800">&lt;!-- E 滑块区域 --&gt;</SPAN><BR></DIV></p>
<p>二、然后是 CSS 部分：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Consolas', 'Lucida Console'; COLOR: #000000" class=source jQuery1303739075546="14"><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">margin</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">0</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">padding</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">0</SPAN><SPAN style="COLOR: #000000">;}</SPAN><BR><SPAN style="COLOR: #000000">#tab</SPAN><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">height</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">180px</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">padding</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">10px</SPAN> <SPAN style="COLOR: #0000ff">20px</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">overflow</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">hidden</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">position</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">relative</SPAN><SPAN style="COLOR: #000000">;}</SPAN><BR><SPAN style="COLOR: #000000">#tabContentB</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">#tabContentC</SPAN><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">display</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">none</SPAN><SPAN style="COLOR: #000000">;}</SPAN><SPAN style="FONT-STYLE: italic; COLOR: #008800">/* 非首块内容区域默认不显示 */</SPAN><BR><SPAN style="COLOR: #000000">#tab</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">div</SPAN><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">height</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">200px</SPAN><SPAN style="COLOR: #000000">;}</SPAN><BR><SPAN style="COLOR: #000000">#switcher</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">li</SPAN><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">width</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">150px</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">height</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">30px</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">line-height</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">30px</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">text-align</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">center</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">float</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">left</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">cursor</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">pointer</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">list-style</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">none</SPAN><SPAN style="COLOR: #000000">;}</SPAN><BR><SPAN style="COLOR: #000000">#switcher</SPAN> <SPAN style="COLOR: #000080; FONT-WEIGHT: bold">span</SPAN><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">width</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">10px</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">height</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">10px</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">overflow</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">hidden</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">position</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">absolute</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">background</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">#000</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">display</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">block</SPAN>;<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">left</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">75px</SPAN><SPAN style="COLOR: #000000">;}</SPAN><BR></DIV></p>
<p>三、js 部分（先加载 jQuery，这个就略过了，你懂的）：</p>
<p><DIV style="FONT-FAMILY: 'Courier New', 'Consolas', 'Lucida Console'; COLOR: #000000" class=source jQuery1303739195125="14"><SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #000000">document</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">ready</SPAN>(<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN><SPAN style="COLOR: #000000">(){</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;li#switcherA&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">hover</SPAN>(<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN> () <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#switcher span&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">stop</SPAN>(<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">true</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">true</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#switcher span&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">animate</SPAN><SPAN style="COLOR: #000000">({</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">left</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">&quot;75px&quot;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">},</SPAN><SPAN style="COLOR: #0000ff">250</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#tabContentA&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">fadeIn</SPAN>(<SPAN style="COLOR: #0000ff">&quot;slow&quot;</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#tabContentB&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">fadeOut</SPAN>(<SPAN style="COLOR: #0000ff">&quot;fast&quot;</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#tabContentC&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">fadeOut</SPAN>(<SPAN style="COLOR: #0000ff">&quot;fast&quot;</SPAN>)<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">});</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;li#switcherB&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">hover</SPAN>(<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN> () <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#switcher span&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">stop</SPAN>(<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">true</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">true</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#switcher span&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">animate</SPAN><SPAN style="COLOR: #000000">({</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">left</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">&quot;225px&quot;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">},</SPAN><SPAN style="COLOR: #0000ff">250</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#tabContentA&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">fadeOut</SPAN>(<SPAN style="COLOR: #0000ff">&quot;fast&quot;</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#tabContentB&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">fadeIn</SPAN>(<SPAN style="COLOR: #0000ff">&quot;slow&quot;</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#tabContentC&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">fadeOut</SPAN>(<SPAN style="COLOR: #0000ff">&quot;fast&quot;</SPAN>)<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">});</SPAN><BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;li#switcherC&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">hover</SPAN>(<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">function</SPAN> () <SPAN style="COLOR: #000000">{</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#switcher span&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">stop</SPAN>(<SPAN style="COLOR: #000080; FONT-WEIGHT: bold">true</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000080; FONT-WEIGHT: bold">true</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#switcher span&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">animate</SPAN><SPAN style="COLOR: #000000">({</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">left</SPAN><SPAN style="COLOR: #000000">:</SPAN><SPAN style="COLOR: #0000ff">&quot;375px&quot;</SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">},</SPAN><SPAN style="COLOR: #0000ff">250</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#tabContentA&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">fadeOut</SPAN>(<SPAN style="COLOR: #0000ff">&quot;fast&quot;</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#tabContentB&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">fadeOut</SPAN>(<SPAN style="COLOR: #0000ff">&quot;fast&quot;</SPAN>);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">$</SPAN>(<SPAN style="COLOR: #0000ff">&quot;#tabContentC&quot;</SPAN><SPAN style="COLOR: #000000">).</SPAN><SPAN style="COLOR: #000000">fadeIn</SPAN>(<SPAN style="COLOR: #0000ff">&quot;slow&quot;</SPAN>)<BR>&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: #000000">});</SPAN><BR><SPAN style="COLOR: #000000">});</SPAN><BR></DIV></p>
<p>这样就完了，总觉得 JS 部分还可以精简，但是实在想不出来了。写以上代码的时候正顶着39.8度的高烧，估计在逻辑上会有些迷糊，原谅我吧，不写两行代码，我实在睡不下去，今天已经请了一天假了，但愿明天写代码的时候不用再含着体温计了。 >_<|||</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/marquee-scroll.html" rel="bookmark" title="基于 jQuery 的图片/文字无缝滚动">基于 jQuery 的图片/文字无缝滚动</a>        <div class="rl_date">2011年12月20日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-highslide-on-demand.html" rel="bookmark" title="jQuery 按需加载 HighSlide 效果">jQuery 按需加载 HighSlide 效果</a>        <div class="rl_date">2011年10月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-slide-loaded-on-demand.html" rel="bookmark" title="jQuery 按需加载轮播图">jQuery 按需加载轮播图</a>        <div class="rl_date">2011年09月26日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/ajax-get-in-jquery.html" rel="bookmark" title="用 jQuery 实现异步跨域请求">用 jQuery 实现异步跨域请求</a>        <div class="rl_date">2011年09月6日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/jquery-sliding-doors.html/feed</wfw:commentRss>
		<slash:comments>134</slash:comments>
		</item>
		<item>
		<title>jQuery/JavaScript 实现的异步加载图片</title>
		<link>http://wange.im/jquery-js-ajax-pic.html</link>
		<comments>http://wange.im/jquery-js-ajax-pic.html#comments</comments>
		<pubDate>Sun, 10 Apr 2011 12:55:34 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[图片]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4745</guid>
		<description><![CDATA[前天我亲奶滴偶像+室友+同事任平生小盆友在为我首页加载的速度上挑刺（YSlow V2下Grade A的我已经神一般的飞速了 O(∩_∩)O~），还真被他一眼挑出几个可以优化的细节之处，比如说首页文章列表页的展开后显示的缩略图，任平生GG 表示，这些图片完全可以不用事先加载，等用户点击展开之后才加载，不点击就不加载。这样一来，以我首页显示10篇文章列表为例，如果每篇缩略图6K左右，一个首页加载就节省了60K左右，何乐而不为呢？ 任平生GG 用的是 jQuery 实现的图片异步加载，而我整理了一下，又折腾了一个 JavaScript 版的图片异步加载效果，两者原理是一样一样的，先请看 DEMO。 在上代码之前先说一下简单的原理，我们知道在 img 标签中的 src 属性是指向图片地址，要实现异步加载，就先暂时不给 src 属性赋值，而是先找个中间变量的属性 data-src，把图片地址写在 data-src 属性里，然后当触发 onclick 事件的时候，把 data-src 的值复制给 src，也就实现了异步加载。 代码时间到，因为无论是 jQuery 还是 JavaScript 的方法，HTML 的结构是相同的，如下： &#60;div id="box"&#62;     &#60;input type="submit" value="异步加载图片" id="submitBtn" /&#62;     &#60;div class="picBox"&#62;         &#60;img data-src="logo.png" alt="" class="logo" /&#62;     &#60;/div&#62; &#60;/div&#62; 先上 jQuery [...]]]></description>
			<content:encoded><![CDATA[<p>前天我亲奶滴偶像+室友+同事<a title="任平生" href="http://rpsh.net/" target="_blank">任平生</a>小盆友在为我首页加载的速度上挑刺（YSlow V2下Grade A的我已经神一般的飞速了 O(∩_∩)O~），还真被他一眼挑出几个可以优化的细节之处，比如说首页文章列表页的展开后显示的缩略图，任平生GG 表示，这些图片完全可以不用事先加载，等用户点击展开之后才加载，不点击就不加载。这样一来，以我首页显示10篇文章列表为例，如果每篇缩略图6K左右，一个首页加载就节省了60K左右，何乐而不为呢？</p>
<p>任平生GG 用的是 jQuery 实现的图片异步加载，而我整理了一下，又折腾了一个 JavaScript 版的图片异步加载效果，两者原理是一样一样的，先请看 <a title="jQuery/JavaScript 实现的异步加载图片" href="http://wange.im/demo/ajax-pic/">DEMO</a>。</p>
<p>在上代码之前先说一下简单的原理，我们知道在 img 标签中的 src 属性是指向图片地址，要实现异步加载，就先暂时不给 src 属性赋值，而是先找个中间变量的属性 data-src，把图片地址写在 data-src 属性里，然后当触发 onclick 事件的时候，把 data-src 的值复制给 src，也就实现了异步加载。</p>
<p>代码时间到，因为无论是 jQuery 还是 JavaScript 的方法，HTML 的结构是相同的，如下：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"box"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;input</span> <span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"submit"</span> <span style="color: #ff0000;">value=</span><span style="color: #0000ff;">"异步加载图片"</span> <span style="color: #ff0000;">id=</span><span style="color: #0000ff;">"submitBtn"</span> <span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"picBox"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
        <span style="color: #000080; font-weight: bold;">&lt;img</span> <span style="color: #ff0000;">data-src=</span><span style="color: #0000ff;">"logo.png"</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">""</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"logo"</span> <span style="color: #000080; font-weight: bold;">/&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span></div>
<p>先上 jQuery 的方法：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #000000;">document</span><span style="color: #000000;">).</span><span style="color: #000000;">ready</span>(<span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#submitBtn'</span><span style="color: #000000;">).</span><span style="color: #000000;">click</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
        <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">imgSrc</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">next</span><span style="color: #000000;">().</span><span style="color: #000000;">find</span>(<span style="color: #0000ff;">'.logo'</span><span style="color: #000000;">).</span><span style="color: #000000;">attr</span>(<span style="color: #0000ff;">'data-src'</span>);<br />
        <span style="color: #000000;">$</span>(<span style="color: #000080; font-weight: bold;">this</span><span style="color: #000000;">).</span><span style="color: #000000;">next</span><span style="color: #000000;">().</span><span style="color: #000000;">find</span>(<span style="color: #0000ff;">'.logo'</span><span style="color: #000000;">).</span><span style="color: #000000;">attr</span>(<span style="color: #0000ff;">'src'</span><span style="color: #000000;">,</span> <span style="color: #000000;">imgSrc</span>);<br />
    <span style="color: #000000;">});</span><br />
<span style="color: #000000;">});</span></div>
<p>再比较一下 JavaScript 的方法：</p>
<div class="source" style="font-family: 'Courier New', 'Lucida Console', 'monospace'; color: #000000;"><span style="color: #000000;">window</span><span style="color: #000000;">.</span><span style="color: #000000;">onload</span> <span style="color: #000000;">=</span> <span style="color: #000080; font-weight: bold;">function</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">getElementById</span>(<span style="color: #0000ff;">'submitBtn'</span><span style="color: #000000;">).</span><span style="color: #000000;">onclick</span> <span style="color: #000000;">=</span> <span style="color: #000000;">submitBtn</span>;<br />
<span style="color: #000000;">}</span><br />
<span style="color: #000080; font-weight: bold;">function</span> <span style="color: #000000;">submitBtn</span><span style="color: #000000;">(){</span><br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">imgTag</span> <span style="color: #000000;">=</span> <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">getElementById</span>(<span style="color: #0000ff;">'box'</span><span style="color: #000000;">).</span><span style="color: #000000;">getElementsByTagName</span>(<span style="color: #0000ff;">'img'</span>);<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">imgSrc</span> <span style="color: #000000;">=</span> <span style="color: #000000;">imgTag</span><span style="color: #000000;">[</span><span style="color: #0000ff;">0</span><span style="color: #000000;">].</span><span style="color: #000000;">getAttribute</span>(<span style="color: #0000ff;">'data-src'</span>);<br />
    <span style="color: #000000;">imgTag</span><span style="color: #000000;">[</span><span style="color: #0000ff;">0</span><span style="color: #000000;">].</span><span style="color: #000000;">setAttribute</span>(<span style="color: #0000ff;">'src'</span><span style="color: #000000;">,</span><span style="color: #000000;">imgSrc</span>);<br />
<span style="color: #000000;">}</span></div>
<p>再来玩一下这个 <a title="jQuery/JavaScript 实现的异步加载图片" href="http://wange.im/demo/ajax-pic/">DEMO</a>，按照这个原理，发现自己写一个 lazyload 的 jQuery 插件也并不是很难嘛，哈哈～</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/ajax/" title="AJAX" rel="tag">AJAX</a>,<a href="http://wange.im/tag/javascript/" title="Javascript" rel="tag">Javascript</a>,<a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/js/" title="JS" rel="tag">JS</a>,<a href="http://wange.im/tag/picture/" title="图片" rel="tag">图片</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/rss2.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标滑动渐隐渐显效果" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadein-and-fadeout-with-jquery.html" rel="bookmark" title="JQuery 鼠标滑动渐隐渐显效果">JQuery 鼠标滑动渐隐渐显效果</a>        <div class="rl_date">2010年05月5日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/fadeto-effect-with-jquery.html" rel="bookmark" title="利用 JQuery 实现图片显隐特效">利用 JQuery 实现图片显隐特效</a>        <div class="rl_date">2010年04月8日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/sweet-titles.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="JQuery 鼠标提示特效之 Sweet Titles" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-sweet-titles-tooltips.html" rel="bookmark" title="JQuery 鼠标提示特效之 Sweet Titles">JQuery 鼠标提示特效之 Sweet Titles</a>        <div class="rl_date">2010年03月14日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/marquee-scroll.html" rel="bookmark" title="基于 jQuery 的图片/文字无缝滚动">基于 jQuery 的图片/文字无缝滚动</a>        <div class="rl_date">2011年12月20日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/jquery-js-ajax-pic.html/feed</wfw:commentRss>
		<slash:comments>121</slash:comments>
		</item>
		<item>
		<title>HTML5 innerShiv 翻译文档</title>
		<link>http://wange.im/html5-innershiv-translated-doc.html</link>
		<comments>http://wange.im/html5-innershiv-translated-doc.html#comments</comments>
		<pubDate>Thu, 10 Mar 2011 16:46:01 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[innerShiv]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4627</guid>
		<description><![CDATA[今天在和亲奶滴攀帅讨论 HTML5 中的 AJAX 效果时发现 HTML5 Shiv 脚本并没有强大到可以解决所有情况下的 IE 兼容问题。HTML5 是个好东东，AJAX 也是个好东东，但是两个好东东放在一起就产生了如此奇妙的问题。 比如说有这样一个实际的问题：有一段带有 HTML5 标签的 blah...blah...blah 要通过 AJAX 加载到当前页面中，但是我们知道为了 HTML5 标签能在 IE 下正常渲染，必须把  HTML5 Shiv 这段脚本置于 head 里，让 IE 在解析标签之前先对新元素有个认识。如此一来，后期通过 AJAX 加载的 HTML5 标签自然不会被渲染到，这样在 IE 下又会产生新的杯具，不停的 AJAX，就是不停地杯具，我勒了个去的~ 我想了很多馊主意去兼容它，比如说把 document.createElement() 放到 AJAX 输出的内容中去；又比如说把 HTML5 标签从 AJAX 内容放到 jQuery 中加载……但是一切的一切都是徒劳，没有根本性解决问题，始终得不到满意的答案。还是攀帅先我一步找到了答案——HTML 5 innerShiv。当我看到这个名字的时候，我就知道有救了，我要的就是 inner 这个感觉，哈哈。 --------------- 以上是废话的分割线 --------------- 无论是 [...]]]></description>
			<content:encoded><![CDATA[<p>今天在和亲奶滴攀帅讨论 HTML5 中的 AJAX 效果时发现 <a title="让 IE 支持 HTML5 标签" href="http://wange.im/html5-for-ie.html">HTML5 Shiv 脚本</a>并没有强大到可以解决所有情况下的 IE 兼容问题。HTML5 是个好东东，AJAX 也是个好东东，但是两个好东东放在一起就产生了如此奇妙的问题。</p>
<p>比如说有这样一个实际的问题：有一段带有 HTML5 标签的 blah...blah...blah 要通过 AJAX 加载到当前页面中，但是我们知道为了 HTML5 标签能在 IE 下正常渲染，必须把  HTML5 Shiv 这段脚本置于 head 里，让 IE 在解析标签之前先对新元素有个认识。如此一来，后期通过 AJAX 加载的 HTML5 标签自然不会被渲染到，这样在 IE 下又会产生新的杯具，不停的 AJAX，就是不停地杯具，我勒了个去的~</p>
<p>我想了很多馊主意去兼容它，比如说把 document.createElement() 放到 AJAX 输出的内容中去；又比如说把 HTML5 标签从 AJAX 内容放到 jQuery 中加载……但是一切的一切都是徒劳，没有根本性解决问题，始终得不到满意的答案。还是攀帅先我一步找到了答案——<a title="HTML 5 innerShiv" href="http://jdbartlett.github.com/innershiv">HTML 5 innerShiv</a>。当我看到这个名字的时候，我就知道有救了，我要的就是 inner 这个感觉，哈哈。</p>
<p>--------------- 以上是废话的分割线 ---------------</p>
<p>无论是 Google 还是百毒，居然都没有找到关于 innerShiv 的中文文档，好吧，我相信总有需要它的朋友，我就花了点时间翻译一下，因为水平有限，难免有误，欢迎指正。如下：</p>
<p><strong>HTML 5 innerShiv</strong></p>
<p>即使使用 Shiv（万戈注：就是指 <a title="让 IE 支持 HTML5 标签" href="http://wange.im/html5-for-ie.html">HTML5 Shiv</a> 脚本），以下代码在 IE 下仍无法正常工作：</p>
<div class="source" style="font-family: 'Courier New','Consolas','Lucida Console'; color: #000000;"><span style="color: #000080; font-weight: bold;">var</span> s <span style="color: #000000;">=</span> <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">createElement</span>(<span style="color: #0000ff;">'div'</span>);<br />
s<span style="color: #000000;">.</span><span style="color: #000000;">innerHTML</span> <span style="color: #000000;">=</span> <span style="color: #0000ff;">"&lt;section&gt;Hi!&lt;/section&gt;"</span>;<br />
<span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">body</span><span style="color: #000000;">.</span><span style="color: #000000;">appendChild</span>(s);</div>
<p>为此，HTML 5 innerShiv 脚本（本文的主角登场）提供了一个解决方法：</p>
<p><strong>出现的问题：</strong></p>
<p>举例来说，一个页面的文档中包含以下样式：</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000080; font-weight: bold;">footer</span><span style="color: #000000;">,</span> <span style="color: #000080; font-weight: bold;">header</span><span style="color: #000000;">,</span> <span style="color: #000080; font-weight: bold;">section</span> <span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">:</span><span style="color: #0000ff;">1px</span> <span style="color: #000080; font-weight: bold;">solid</span> <span style="color: #0000ff;">#ccc</span>;<br />
    <span style="color: #000080; font-weight: bold;">display</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">block</span>;<br />
    <span style="color: #000080; font-weight: bold;">padding</span><span style="color: #000000;">:</span><span style="color: #0000ff;">10px</span>;<br />
<span style="color: #000000;">}</span></div>
<p>如你所见，section 标签被灰色的边框包起来了，在 <a title="HTML5 shiv" href="http://html5shiv.googlecode.com/svn/trunk/html5.js" target="_blank">the HTML 5 shiv</a> 的帮助下，甚至 IE 都能实现这个效果。</p>
<p>然而，当一个页面加载了 shiv 脚本，而在此之前，有一个元素的内容用 innerHTML 追加到页面中，那 shiv 脚本在 IE 浏览器下就是无效的。这是一种常见的情况，显然，当你调用 jQuery 这类库时，使用 append 或者 load 等方法载入 HTML5 内容也是同样不行的，例如：</p>
<p><strong>例一：</strong>不完整的 section 标签</p>
<p>照理来说，这个 section 元素应该有一条灰色边框。但是在 IE 浏览器中却没有 <img src='http://wange.im/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#example-1'</span><span style="color: #000000;">).</span><span style="color: #000000;">append</span>(<span style="color: #0000ff;">"&lt;section&gt;&lt;header&gt;&lt;h3&gt;Example 1:\</span><br />
<span style="color: #0000ff;">  a broken section&lt;/h3&gt;&lt;/header&gt;&lt;p&gt;This section element should\</span><br />
<span style="color: #0000ff;">  have a black border like the others. It doesn't in Internet\</span><br />
<span style="color: #0000ff;">  Explorer.&lt;/p&gt;&lt;/section&gt;"</span>);</div>
<p><strong>解决方法：</strong></p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000000;">innerShiv</span>(<span style="color: #0000ff;">"&lt;section&gt;html string&lt;/section&gt;"</span>)</div>
<p>innerShiv 是一个函数，它可以接受你的 HTML 字符串，将它作为一个隐藏的附加文档添加到 IE 浏览器中，并返回一个 IE 下安全的文档片段或集合。</p>
<p><strong>例二：</strong>成功定义样式的 section</p>
<p>照理来说，这个 section 元素应该有一条灰色边框。事实上它确实有！甚至在 IE 下也有！哦耶~</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#example-2'</span><span style="color: #000000;">).</span><span style="color: #000000;">append</span>(<span style="color: #000000;">innerShiv</span>(<span style="color: #0000ff;">"&lt;section&gt;&lt;header&gt;&lt;h3&gt;\</span><br />
<span style="color: #0000ff;">  Example 2: a successfully styled section&lt;/h3&gt;&lt;/header&gt;\</span><br />
<span style="color: #0000ff;">  &lt;p&gt;This section element should have a gray border like the\</span><br />
<span style="color: #0000ff;">  others. And it does! Even in Internet Explorer! Yay!.&lt;/p&gt;\</span><br />
<span style="color: #0000ff;">  &lt;/section&gt;"</span>));</div>
<p>innerShiv <strong>不需要 jQuery 或者其他库</strong>。因为它返回的是文档碎片，你可以用 appendChild 或者其他的方法追加它的返回值。</p>
<p><strong>例三：</strong>看吧，不需要 jQuery</p>
<p>用 appendChild 来追加 section 元素的内容。</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000080; font-weight: bold;">var</span> s <span style="color: #000000;">=</span> <span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">createElement</span>(<span style="color: #0000ff;">'section'</span>);<br />
s<span style="color: #000000;">.</span><span style="color: #000000;">appendChild</span>(<span style="color: #000000;">innerShiv</span>(<span style="color: #0000ff;">"&lt;header&gt;&lt;h3&gt;Example 3: look, ma:\</span><br />
<span style="color: #0000ff;">  no jQuery&lt;/h3&gt;&lt;/header&gt;&lt;p&gt;This section element's contents\</span><br />
<span style="color: #0000ff;">  have been added with appendChild.&lt;/p&gt;"</span>));<br />
<span style="color: #000000;">document</span><span style="color: #000000;">.</span><span style="color: #000000;">getElementById</span>(<span style="color: #0000ff;">'example-3'</span><span style="color: #000000;">).</span><span style="color: #000000;">appendChild</span>(s);</div>
<p><strong>用 jQuery 的注意事项</strong></p>
<p>当你用 innerShiv 创建了一个 jQuery 对象，你应该传递给第二个参数一个 false 的布尔值，用来指示 innerShiv 返回一个数组元素，而不是一个文档片段。</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #000000;">innerShiv</span>(<span style="color: #0000ff;">"html string"</span><span style="color: #000000;">,</span> <span style="color: #000080; font-weight: bold;">false</span>))</div>
<p>这可以让你在文档中插入内容之前做进一步的操作。</p>
<p><strong>例四：</strong>返回节点，而不是一个片段</p>
<p>用 jQuery 使 section 元素被 innerShiv 控制。</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000000;">$</span>(<span style="color: #0000ff;">'#example-4'</span><span style="color: #000000;">).</span><span style="color: #000000;">append</span>(<br />
  <span style="color: #000000;">$</span>(<span style="color: #000000;">innerShiv</span>(<br />
    <span style="color: #0000ff;">"&lt;section&gt;&lt;header&gt;\</span><br />
<span style="color: #0000ff;">      &lt;h3&gt;Example 4: &lt;/h3&gt;&lt;/header&gt;&lt;p&gt;This section's\</span><br />
<span style="color: #0000ff;">      innerShiv'd header was manipulated with jQuery.\</span><br />
<span style="color: #0000ff;">      &lt;/p&gt;&lt;/section&gt;"</span><span style="color: #000000;">,</span><br />
    <span style="color: #000080; font-weight: bold;">false</span><br />
  ))<br />
  <span style="color: #000000;">.</span><span style="color: #000000;">find</span>(<span style="color: #0000ff;">'h3'</span>)<br />
    <span style="color: #000000;">.</span><span style="color: #000000;">append</span>(<span style="color: #0000ff;">'returning nodes instead of a fragment'</span>)<br />
  <span style="color: #000000;">.</span><span style="color: #000000;">end</span>()<br />
);</div>
<p>有一个常见的问题，如果使用 jQuery 的 load() 方法调用 innerShiv。这种想法提供了一个替代的方法，loadShiv()，它是基于 jQuery 的 load() 方法，但是通过 innerShiv 在 DOM 中添加任何内容之前引入 HTML。单独<a title="loadShiv" href="https://gist.github.com/735829" target="_blank">下载 loadShiv</a>，把它加载到你的项目中去，然后用 loadShiv() 替换 load() 即可。</p>
<p><strong>下载：</strong></p>
<p><a title="innershiv.js - 未压缩版本" href="http://jdbartlett.github.com/innershiv/innershiv.js" target="_blank">innershiv.js</a> - 未压缩版本   <a title="innershiv.js.min - 压缩版本" href="http://jdbartlett.github.com/innershiv/innershiv.min.js" target="_blank">innershiv.js.min</a> - 压缩版本</p>
<p>原文地址：<a title="HTML 5 innerShiv" href="http://jdbartlett.github.com/innershiv/" target="_blank">http://jdbartlett.github.com/innershiv/</a></p>
<p>呼呼，完毕，翻译文档真是一件累人的活，以后没事尽量少干。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/ajax/" title="AJAX" rel="tag">AJAX</a>,<a href="http://wange.im/tag/html5/" title="HTML5" rel="tag">HTML5</a>,<a href="http://wange.im/tag/innershiv/" title="innerShiv" rel="tag">innerShiv</a>,<a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/ajax-get-in-jquery.html" rel="bookmark" title="用 jQuery 实现异步跨域请求">用 jQuery 实现异步跨域请求</a>        <div class="rl_date">2011年09月6日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-js-ajax-pic.html" rel="bookmark" title="jQuery/JavaScript 实现的异步加载图片">jQuery/JavaScript 实现的异步加载图片</a>        <div class="rl_date">2011年04月10日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/screenshot.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="新年新气象，博客换新衣" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/new-year-new-theme.html" rel="bookmark" title="新年新气象，博客换新衣">新年新气象，博客换新衣</a>        <div class="rl_date">2012年01月20日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/marquee-scroll.html" rel="bookmark" title="基于 jQuery 的图片/文字无缝滚动">基于 jQuery 的图片/文字无缝滚动</a>        <div class="rl_date">2011年12月20日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/html5-innershiv-translated-doc.html/feed</wfw:commentRss>
		<slash:comments>82</slash:comments>
		</item>
		<item>
		<title>jQuery 水平拖动效果</title>
		<link>http://wange.im/jquery-drag.html</link>
		<comments>http://wange.im/jquery-drag.html#comments</comments>
		<pubDate>Fri, 04 Mar 2011 14:23:52 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[pagenavi]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4607</guid>
		<description><![CDATA[我本来没想单独写这篇文章的，不过昨天已经写了 WordPress 拖动分页的核心代码，今天索性就把这剩余的水平拖动效果也拿出来说一说。之前看过一些关于 jQuery 实现的水平拖动的效果，大多数是一些插件之类的，都要加载超多超多超没用的 JS，相比较而言，以下我说的方法是我认为最为精简的方法，而且效果也很棒。最关键的是，像我这样有页面洁癖的人，一向是以速度优先的，所以 JS 这种东西，越精简越好。 我直接把首页右侧案例展示的拖动模块提取出来做了一个 DEMO，为了避免 JS 上的混淆，我把案例展示部分的点击放大效果去掉了，只留下单纯的 jQuery 拖动效果。下面是分解过程： 一、HTML 部分 &#60;div class="drag"&#62;     &#60;div class="drag_cont"&#62;         &#60;ul class="drag_ul"&#62;             &#60;li&#62;&#60;img alt="SunMusic" src="http://wange.im/wp-content/themes/wange/images/works/sunmusic_s.jpg" /&#62;&#60;/li&#62;             &#60;li&#62;&#60;img alt="WanGe" src="http://wange.im/wp-content/themes/wange/images/works/wange_s.jpg" /&#62;&#60;/li&#62;             &#60;li&#62;&#60;img alt="DustMedia" src="http://wange.im/wp-content/themes/wange/images/works/dustmedia_s.jpg" /&#62;&#60;/li&#62;             &#60;li&#62;&#60;img alt="BlueLaw" src="http://wange.im/wp-content/themes/wange/images/works/bluelaw_s.jpg" /&#62;&#60;/li&#62;             &#60;li&#62;&#60;img alt="DarkSide" src="http://wange.im/wp-content/themes/wange/images/works/darkside_s.jpg" /&#62;&#60;/li&#62;             &#60;li&#62;&#60;img alt="ChinaBlogs" src="http://wange.im/wp-content/themes/wange/images/works/chinablogs_s.jpg" /&#62;&#60;/li&#62;             [...]]]></description>
			<content:encoded><![CDATA[<p>我本来没想单独写这篇文章的，不过昨天已经写了 <a title="显示 WordPress 所有分页页码" href="http://wange.im/show-all-pages-for-wordpress.html">WordPress 拖动分页</a>的核心代码，今天索性就把这剩余的水平拖动效果也拿出来说一说。之前看过一些关于 jQuery 实现的水平拖动的效果，大多数是一些插件之类的，都要加载超多超多超没用的 JS，相比较而言，以下我说的方法是我认为最为精简的方法，而且效果也很棒。最关键的是，像我这样有页面洁癖的人，一向是以速度优先的，所以 JS 这种东西，越精简越好。</p>
<p>我直接把首页右侧案例展示的拖动模块提取出来做了一个 <a title="jQuery 水平拖动效果" href="http://wange.im/demo/drag/">DEMO</a>，为了避免 JS 上的混淆，我把案例展示部分的点击放大效果去掉了，只留下单纯的 jQuery 拖动效果。下面是分解过程：</p>
<p><strong>一、HTML 部分</strong></p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"drag"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"drag_cont"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
        <span style="color: #000080; font-weight: bold;">&lt;ul</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"drag_ul"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"SunMusic"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/sunmusic_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"WanGe"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/wange_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"DustMedia"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/dustmedia_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"BlueLaw"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/bluelaw_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"DarkSide"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/darkside_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"ChinaBlogs"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/chinablogs_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"OrgRisk"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/orgrisk_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"WOYO"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/woyo_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"FML"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/fml_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"MusicWeiWei"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/musicweiwei_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"YupNews"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/yupnews_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"xinwanbiao"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/xwb_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"RedLaw"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/redlaw_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"WJJ"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/wjj_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
            <span style="color: #000080; font-weight: bold;">&lt;li&gt;&lt;img</span> <span style="color: #ff0000;">alt=</span><span style="color: #0000ff;">"XinTai"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"http://wange.im/wp-content/themes/wange/images/works/xintai_s.jpg"</span> <span style="color: #000080; font-weight: bold;">/&gt;&lt;/li&gt;</span><br />
        <span style="color: #000080; font-weight: bold;">&lt;/ul&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span><br />
    <span style="color: #000080; font-weight: bold;">&lt;div</span> <span style="color: #ff0000;">class=</span><span style="color: #0000ff;">"drag_cont_btn"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;/div&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/div&gt;</span></div>
<p><strong>二、脚本部分</strong></p>
<p>这是本文的重点了，首先要挂一个 jQuery，这就不多说了。然后还要挂一个 jQuery UI 的组件，关于 jQuery UI 的组件介绍和下载可以<a title="jQuery UI" href="http://jqueryui.com/download">点击这里</a>，下载 jQuery UI 后，我们这里只需要其中的 ui.core.min.js 和 ui.slider.min.js 这两个。接下来在页面中依次引用以下脚本：</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"js/jquery.js"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;/script&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"js/ui.core.min.js"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;/script&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span> <span style="color: #ff0000;">src=</span><span style="color: #0000ff;">"js/ui.slider.min.js"</span><span style="color: #000080; font-weight: bold;">&gt;&lt;/script&gt;</span><br />
<span style="color: #000080; font-weight: bold;">&lt;script </span><span style="color: #ff0000;">type=</span><span style="color: #0000ff;">"text/javascript"</span><span style="color: #000080; font-weight: bold;">&gt;</span><br />
<span style="color: #000000;">$</span>(<span style="color: #000000;">document</span><span style="color: #000000;">).</span><span style="color: #000000;">ready</span>(<span style="color: #000080; font-weight: bold;">function</span>() <span style="color: #000000;">{</span><br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">$contain</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".drag_ul"</span><span style="color: #000000;">,</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".drag"</span>));<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">$items</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">"li"</span><span style="color: #000000;">,</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".drag .drag_ul"</span>));<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">$dragCont</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".drag_cont"</span><span style="color: #000000;">,</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".drag"</span>));<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">$button</span> <span style="color: #000000;">=</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".drag_cont_btn"</span><span style="color: #000000;">,</span> <span style="color: #000000;">$</span>(<span style="color: #0000ff;">".drag"</span>));<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">width</span> <span style="color: #000000;">=</span> (<span style="color: #000000;">$items</span><span style="color: #000000;">.</span><span style="color: #000000;">length</span> <span style="color: #000000;">*</span> <span style="color: #000000;">parseInt</span>(<span style="color: #000000;">$items</span><span style="color: #000000;">.</span><span style="color: #000000;">outerWidth</span>(<span style="color: #000080; font-weight: bold;">true</span>)));<br />
    <span style="color: #000000;">$contain</span><span style="color: #000000;">.</span><span style="color: #000000;">css</span>(<span style="color: #0000ff;">"width"</span><span style="color: #000000;">,</span> <span style="color: #000000;">width</span>);<br />
    <span style="color: #000080; font-weight: bold;">var</span> <span style="color: #000000;">sliderOpts</span> <span style="color: #000000;">=</span> <span style="color: #000000;">{</span><br />
        <span style="color: #000000;">max</span><span style="color: #000000;">:</span> <span style="color: #000000;">width</span> <span style="color: #000000;">-</span> <span style="color: #000000;">parseInt</span>(<span style="color: #000000;">$dragCont</span><span style="color: #000000;">.</span><span style="color: #000000;">css</span>(<span style="color: #0000ff;">"width"</span><span style="color: #000000;">)),</span><br />
        <span style="color: #000000;">slide</span><span style="color: #000000;">:</span> <span style="color: #000080; font-weight: bold;">function</span>(<span style="color: #000000;">e</span><span style="color: #000000;">,</span> <span style="color: #000000;">ui</span>) <span style="color: #000000;">{</span><br />
            <span style="color: #000000;">$contain</span><span style="color: #000000;">.</span><span style="color: #000000;">css</span>(<span style="color: #0000ff;">"left"</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">"-"</span> <span style="color: #000000;">+</span> <span style="color: #000000;">ui</span><span style="color: #000000;">.</span><span style="color: #000000;">value</span> <span style="color: #000000;">+</span> <span style="color: #0000ff;">"px"</span>)<br />
        <span style="color: #000000;">}</span><br />
    <span style="color: #000000;">};</span><br />
    <span style="color: #000000;">$button</span><span style="color: #000000;">.</span><span style="color: #000000;">slider</span>(<span style="color: #000000;">sliderOpts</span>);</div>
<p><span style="color: #000000;">});</span><br />
<span style="color: #000080; font-weight: bold;">&lt;/script&gt;</span></p>
<p><strong>三、样式部分</strong></p>
<p>这里就只提供一个参考的样式吧，或许你有更好更帅的写法。</p>
<div class="source" style="font-family: 'Courier New', 'Consolas', 'Lucida Console'; color: #000000;"><span style="color: #000080; font-weight: bold;">img</span><span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span> <span style="color: #000080; font-weight: bold;">none</span><span style="color: #000000;">;}</span><br />
<span style="color: #000080; font-weight: bold;">ul</span><span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">margin</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">.drag</span><span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">width</span><span style="color: #000000;">:</span><span style="color: #0000ff;">341px</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">.drag</span> <span style="color: #000000;">.drag_cont</span><span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">width</span><span style="color: #000000;">:</span><span style="color: #0000ff;">323px</span>;<span style="color: #000080; font-weight: bold;">height</span><span style="color: #000000;">:</span><span style="color: #0000ff;">80px</span>;<span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">relative</span>;<span style="color: #000080; font-weight: bold;">overflow</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">hidden</span>;<span style="color: #000080; font-weight: bold;">margin</span><span style="color: #000000;">:</span><span style="color: #0000ff;">10px</span> <span style="color: #0000ff;">9px</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">.drag</span> <span style="color: #000080; font-weight: bold;">ul</span><span style="color: #000000;">.drag_ul</span><span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">height</span><span style="color: #000000;">:</span><span style="color: #0000ff;">80px</span>;<span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">absolute</span>;<span style="color: #000080; font-weight: bold;">padding</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">.drag</span> <span style="color: #000080; font-weight: bold;">ul</span><span style="color: #000000;">.drag_ul</span> <span style="color: #000080; font-weight: bold;">li</span><span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">width</span><span style="color: #000000;">:</span><span style="color: #0000ff;">100px</span>;<span style="color: #000080; font-weight: bold;">height</span><span style="color: #000000;">:</span><span style="color: #0000ff;">80px</span>;<span style="color: #000080; font-weight: bold;">display</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">inline</span>;<span style="color: #000080; font-weight: bold;">float</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">left</span>;<span style="color: #000080; font-weight: bold;">margin</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span> <span style="color: #0000ff;">1px</span>;<span style="color: #000080; font-weight: bold;">padding</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span>;<span style="color: #000080; font-weight: bold;">background</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">none</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">.drag</span> <span style="color: #000080; font-weight: bold;">ul</span><span style="color: #000000;">.drag_ul</span> <span style="color: #000080; font-weight: bold;">li</span> <span style="color: #000080; font-weight: bold;">a</span> <span style="color: #000080; font-weight: bold;">img</span><span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">width</span><span style="color: #000000;">:</span><span style="color: #0000ff;">100px</span>;<span style="color: #000080; font-weight: bold;">height</span><span style="color: #000000;">:</span><span style="color: #0000ff;">80px</span>;<span style="color: #000080; font-weight: bold;">display</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">block</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">.drag</span> <span style="color: #000000;">.drag_cont_btn</span><span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">height</span><span style="color: #000000;">:</span><span style="color: #0000ff;">5px</span>;<span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">relative</span>;<span style="color: #000080; font-weight: bold;">border</span><span style="color: #000000;">:</span><span style="color: #0000ff;">1px</span> <span style="color: #000080; font-weight: bold;">solid</span> <span style="color: #0000ff;">#C8C8C8</span>;<span style="color: #000080; font-weight: bold;">margin</span><span style="color: #000000;">:</span><span style="color: #0000ff;">0</span> <span style="color: #0000ff;">10px</span> <span style="color: #0000ff;">10px</span><span style="color: #000000;">;}</span><br />
<span style="color: #000000;">.ui-slider</span> <span style="color: #000000;">.ui-slider-handle</span><span style="color: #000000;">{</span><span style="color: #000080; font-weight: bold;">width</span><span style="color: #000000;">:</span><span style="color: #0000ff;">20px</span>;<span style="color: #000080; font-weight: bold;">height</span><span style="color: #000000;">:</span><span style="color: #0000ff;">20px</span>;<span style="color: #000080; font-weight: bold;">cursor</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">pointer</span>;<span style="color: #000080; font-weight: bold;">overflow</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">hidden</span>;<span style="color: #000080; font-weight: bold;">background</span><span style="color: #000000;">:</span><span style="color: #0000ff;">url(images/drag_btn.gif)</span> <span style="color: #000080; font-weight: bold;">no-repeat</span>;<span style="color: #000080; font-weight: bold;">position</span><span style="color: #000000;">:</span><span style="color: #000080; font-weight: bold;">absolute</span>;<span style="color: #000080; font-weight: bold;">top</span><span style="color: #000000;">:-</span><span style="color: #0000ff;">8px</span>;<span style="color: #000080; font-weight: bold;">margin-left</span><span style="color: #000000;">:-</span><span style="color: #0000ff;">10px</span><span style="color: #000000;">;}</span></div>
<p>我所能做的只是抛砖引玉，更多巧妙的用法欢迎来交流 o(∩_∩)o</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/pagenavi/" title="pagenavi" rel="tag">pagenavi</a>,<a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/show-all-pages-for-wordpress.html" rel="bookmark" title="显示 Wordpress 所有分页页码">显示 Wordpress 所有分页页码</a>        <div class="rl_date">2011年03月3日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wp-postviews-optimization-in-wordpress.html" rel="bookmark" title="Wordpress 速度优化之 WP-PostViews 插件">Wordpress 速度优化之 WP-PostViews 插件</a>        <div class="rl_date">2011年02月9日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/change-font-size-width-jquery.html" rel="bookmark" title="jQuery 控制字体大小切换">jQuery 控制字体大小切换</a>        <div class="rl_date">2011年01月6日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/timthumb.php?src=http://wange.im/cache/sub-menu.jpg&amp;h=45&amp;w=45&amp;zc=1" alt="WordPress 3.0 菜单功能支持二级菜单" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/sub-menu-in-wordpress-3.html" rel="bookmark" title="WordPress 3.0 菜单功能支持二级菜单">WordPress 3.0 菜单功能支持二级菜单</a>        <div class="rl_date">2010年08月29日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/jquery-drag.html/feed</wfw:commentRss>
		<slash:comments>103</slash:comments>
		</item>
		<item>
		<title>WordPress 速度优化之 WP-PostViews 插件</title>
		<link>http://wange.im/wp-postviews-optimization-in-wordpress.html</link>
		<comments>http://wange.im/wp-postviews-optimization-in-wordpress.html#comments</comments>
		<pubDate>Wed, 09 Feb 2011 13:58:43 +0000</pubDate>
		<dc:creator>万戈</dc:creator>
				<category><![CDATA[电脑网络]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[插件]]></category>
		<category><![CDATA[统计]]></category>

		<guid isPermaLink="false">http://wange.im/?p=4518</guid>
		<description><![CDATA[之前我一直在用 WP-PostViews 统计插件，这是一款 WordPress 中老牌的点击量统计插件，很好很强大。而 Willin 大师在最近推出了一款功能更给力的my-visitors 統計插件，我前段时间就一直在试用这个插件，速度和功能上都没话说，但是最近我发现这款插件在我的主题上应用还是有些瑕疵，比如说后台统计功能不能正常使用。所以又换回了 WP-PostViews 这款插件，Willin 大师的 my-vistors 插件的统计数据可以无缝衔接到 WP-PostViews 上，这就太好了。 又要但是了，我发现 WP-PostViews 会在除了首页之外的所有页面上加载一段 jQuery，而且会强行被放到头部加载，即使我用 wp_register_script() 定义了 jQuery 在底部执行，WP-PostViews 还会把我的 jQuery 拖到顶部去。当然这个不会影响最终的执行效果，但是根据 Yslow 的建议，我们最好是把 jQuery 之类的脚本放到底部加载，这样可以加快页面载入的速度。研究了一下 WP-PostViews 插件的代码，发现了其中的奥妙，在 wp-postviews.php 的第59行中，add_action('wp_head', 'process_postviews'); 看到没 wp_head，我就说呢，怎么老是给我提到顶部去，把这里的 wp_head 改成 wp_footer 就可以了。 再再但是，不管怎么样，我都不建议修改插件，因为如果插件今后一旦有升级，那就需要重新修改过，这也就是为什么我同样不建议修改 WordPress 源程序的原因。有什么问题，我们在自己的主题里就将其解决那是最好不过的了。既然 WP-PostViews 是通过勾子把 process_postviews() 函数勾进去的，那我们完全可以注销这个勾子，重新定义到底部嘛。方法如下，把以下代码复制进你 WordPress 主题的 functions.php 文件中： if ( has_action( 'wp_head', [...]]]></description>
			<content:encoded><![CDATA[<p>之前我一直在用 WP-PostViews 统计插件，这是一款 WordPress 中老牌的点击量统计插件，很好很强大。而 Willin 大师在最近推出了一款功能更给力的<a title="my-visitors 統計插件" rel="nofollow" href="http://kan.willin.org/?p=1335" target="_blank">my-visitors 統計插件</a>，我前段时间就一直在试用这个插件，速度和功能上都没话说，但是最近我发现这款插件在我的主题上应用还是有些瑕疵，比如说后台统计功能不能正常使用。所以又换回了 WP-PostViews 这款插件，Willin 大师的 my-vistors 插件的统计数据可以无缝衔接到 WP-PostViews 上，这就太好了。</p>
<p>又要但是了，我发现 WP-PostViews 会在除了首页之外的所有页面上加载一段 jQuery，而且会强行被放到头部加载，即使我用 wp_register_script() 定义了 jQuery 在底部执行，WP-PostViews 还会把我的 jQuery 拖到顶部去。当然这个不会影响最终的执行效果，但是根据 Yslow 的建议，我们最好是把 jQuery 之类的脚本放到底部加载，这样可以加快页面载入的速度。研究了一下 WP-PostViews 插件的代码，发现了其中的奥妙，在 wp-postviews.php 的第59行中，add_action('wp_head', 'process_postviews'); 看到没 wp_head，我就说呢，怎么老是给我提到顶部去，把这里的 wp_head 改成 wp_footer 就可以了。</p>
<p>再再但是，不管怎么样，我都不建议修改插件，因为如果插件今后一旦有升级，那就需要重新修改过，这也就是为什么我同样不建议修改 WordPress 源程序的原因。有什么问题，我们在自己的主题里就将其解决那是最好不过的了。既然 WP-PostViews 是通过勾子把 process_postviews() 函数勾进去的，那我们完全可以注销这个勾子，重新定义到底部嘛。方法如下，把以下代码复制进你 WordPress 主题的 functions.php 文件中：</p>
<div class="source" style="color: #000000; font-family: 'Courier New','Lucida Console','monospace';"><span style="font-weight: bold; color: #000080;">if</span> ( <span style="color: #000000;">has_action</span>( <span style="color: #0000ff;">'wp_head'</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">'process_postviews'</span> ) ) <span style="color: #000000;">{</span><br />
    <span style="color: #000000;">remove_action</span>(<span style="color: #0000ff;">'wp_head'</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">'process_postviews'</span>);<br />
    <span style="color: #000000;">add_action</span>(<span style="color: #0000ff;">'wp_footer'</span><span style="color: #000000;">,</span> <span style="color: #0000ff;">'process_postviews'</span>);<br />
<span style="color: #000000;">}</span></div>
<p>代码如此简单，我就不解释了。现在再来看看页面，功能一切照常，而 jQuery 可以放到底部来执行了，速度上就可以更快一筹。</p>
<p>最后的但是，使用此方法加快页面速度有两个前提：</p>
<p>1、你的所有脚本本来就是放在底部的，否则的话，jQuery 的执行脚本在头部，而 jQuery 库被放到底部来执行，那样顺序就错了，适得其反。</p>
<p>2、确保你的 footer.php 里有 wp_footer() 这个函数，否则勾子没地方挂，用这个方法也是白搭。</p>
<p>建议两类童鞋可以试用此方法：</p>
<p>1、和我一样是速度控的童鞋，为了一点点速度上的优化不则手段。</p>
<p>2、和我一样是代码控的童鞋，为了一点点功能上的优化不则手段。</p>
<div id="rl_posts">    <div id="rl_posts_hd" class="box_hd">        <span id="rl_posts_title" class="box_title">与 <h2 itemprop="keywords"><a href="http://wange.im/tag/jquery/" title="jQuery" rel="tag">jQuery</a>,<a href="http://wange.im/tag/wordpress/" title="WordPress" rel="tag">WordPress</a>,<a href="http://wange.im/tag/plugins/" title="插件" rel="tag">插件</a>,<a href="http://wange.im/tag/statistics/" title="统计" rel="tag">统计</a></h2> 相关的文章        </span>    </div>    <div id="rl_posts_bd">        <ul class="clearfix"><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wordpress-recent-popular-posts.html" rel="bookmark" title="Wordpress 近期最受欢迎的日志">Wordpress 近期最受欢迎的日志</a>        <div class="rl_date">2011年02月12日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wg-ie6warn.html" rel="bookmark" title="WordPress 之万戈牌 Fuck IE6 插件">WordPress 之万戈牌 Fuck IE6 插件</a>        <div class="rl_date">2011年05月12日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/wordpress-is-not-everything.html" rel="bookmark" title="Wordpress 我变我变我变变变">Wordpress 我变我变我变变变</a>        <div class="rl_date">2011年04月27日</div>    </div></li><li>    <div class="rl_thumb"><img src="http://wange.im/wp-content/themes/wange/imgs/category/computer.jpg" alt="电脑网络" width="45" height="45" itemprop="thumbnailUrl" />    </div>    <div class="rl_title">        <a href="http://wange.im/jquery-drag.html" rel="bookmark" title="jQuery 水平拖动效果">jQuery 水平拖动效果</a>        <div class="rl_date">2011年03月4日</div>    </div></li>        </ul>    </div></div>]]></content:encoded>
			<wfw:commentRss>http://wange.im/wp-postviews-optimization-in-wordpress.html/feed</wfw:commentRss>
		<slash:comments>134</slash:comments>
		</item>
	</channel>
</rss>

