<?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>Bolo的博客 &#187; jQuery</title>
	<atom:link href="http://blog.imbolo.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.imbolo.com</link>
	<description>一个设计爱好者杂七杂八的博客</description>
	<lastBuildDate>Wed, 01 Sep 2010 04:34:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery选择器详解（一）</title>
		<link>http://blog.imbolo.com/jquery-selectors/</link>
		<comments>http://blog.imbolo.com/jquery-selectors/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 01:57:18 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.imbolo.com/?p=1890</guid>
		<description><![CDATA[jQuery 的选择器借鉴了大量 CSS1 ~ CSS3 标准的特点，并且整理成一个强大的对象选择工具集。]]></description>
			<content:encoded><![CDATA[<p>jQuery 的选择器借鉴了大量 CSS1 ~ CSS3 标准的特点，并且整理成一个强大的对象选择工具集。但要注意的是如果你的对象名里包含 “<em>#;&#038;,.+*~&#8217;:&#8221;!^$[]()=>|/</em>” 这些元字符时，你必须用 “<em>\\</em>” 进行转义。例如你要选择文档里包含 “<em>name=&#8221;names[]&#8220;</em>” 的 input 元素时，在编写过滤规则时你必须先对 “<em>[]</em>” 进行转义，所以我们应该这样定义选择器：“<em>$(&#8220;input[name=names\\[\\]]&#8221;)</em>”。<span id="more-1890"></span></p>
<h3>泛选择器（*）</h3>
<p>在 jQuery 选择器里，“*” 号是一个通配符，表示所有。例如：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;*&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;border&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;3px solid red&quot;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>上面的一句表示遍历页面里的所有容器，并且全部赋予一个线宽为 3px 的红色实线边框。还有一种情况是我们只需要对某些容器里的内容进行操作，我们可以这样写：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#test&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;*&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;border&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;3px solid red&quot;</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>上一句只对 ID 为 test 的容器里的子容器产生效果，为它们加上线宽为 3px 的红色实现边框。</p>
<h3>:animated 选择器</h3>
<p>:animated 选择器是用来选择当前执行 jQuery 动画的元素的，严格来说是一个特征过滤器。例如：在空 HTML 文档里建一些 Div ，其中一个 ID 为 mover ，然后编写以下的 jQuery 语句</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#mover&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideToggle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #339933;">,</span> animateIt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div:animated&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggleClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;colored&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>上面的代码执行后将先找到 ID 为 mover 的元素，并不断地进行展开和收缩的动画。然后浏览器遍历页面里所有的 Div 标签，如果该 Div （在这个例子里也就是 ID 为 mover 的 Div 了）正在执行动画的话，jQuery 将为这个 Div 加上 class=&#8221;colored&#8221;。具体的 Demo 可以看<a href="http://api.jquery.com/animated-selector/">这个页面</a>。</p>
<h3>属性选择器</h3>
<p>jQuery 的属性选择器是其所有选择器最强大的一个，也是最灵活复杂的，具体情况还可以继续进行细分。</p>
<h4>属性字头选择器（Attribute Contains Prefix Selector）</h4>
<p>jQuery 属性字头选择器的使用格式是 <strong>jQuery(&#8216;[attribute|=value]&#8216;)</strong> ，例如 <strong>jQuery(&#8216;[herflang|=en]&#8216;)</strong> 这句代码执行时将会选择文档中所有含有 herflang 属性，并且 herflang 的值以 “en” 开头的元素，即使 “en” 后面紧跟着连字符 “-” 也能进行选择。</p>
<h4>属性开头选择器（Attribute Starts With Selector）</h4>
<p><strong>jQuery(&#8216;[attribute^=value]&#8216;)</strong> ，用于选择属性的值以某个字符串开头的元素，但和 <strong>jQuery(&#8216;[attribute|=value]&#8216;)</strong> 的区别是，如果 value 的后面是一个连字符的话，这个元素不会被选择。例如 <strong>jQuery(&#8216;[rel^=no]&#8216;)</strong> 将会选择所有 rel 的值以 “no” 开头的元素，但类似于 rel=&#8221;no-****&#8221; 的元素不会被选择。</p>
<h4>属性包含选择器（Attribute Contains Selector）</h4>
<p>基本使用方法为 <strong>jQuery(&#8216;[attribute*=value]&#8216;)</strong>，例如 <strong>jQuery(&#8216;[rel*=no]&#8216;)</strong>，表示所有带有 rel 属性，并且 rel 的值里包含子字符串 “no” 的元素（如 rel=&#8221;nofollow&#8221;，rel=&#8221;yesorno&#8221; 等等）都将会被选择。</p>
<h4>属性单词选择器（Attribute Contains Word Selector）</h4>
<p><strong>jQuery(&#8216;[attribute~=value]&#8216;)</strong>，这个选择器的特别之处在于 value 的值只能必须是一个独立的单词（或者是字符串），例如 <strong>jQuery(&#8216;[rel~=no]&#8216;)</strong> ，此句在执行的时候会选择带有 rel=&#8221;yes or no&#8221; 的元素，但不会选择带有 rel=&#8221;yesorno&#8221; 的元素。这个选择器可以看做属性包含选择器的补充品，用于需要进行严格匹配的时候。</p>
<h4>属性结尾选择器（Attribute Ends With Selector）</h4>
<p><strong>jQuery(&#8216;[attribute$=value]&#8216;)</strong> ，用于选择特定属性的值以某个字符串结尾的元素，例如 <strong>jQuery(&#8216;[rel$=no]&#8216;)</strong> 将会选择 rel 属性的值以 “no” 结尾的元素。</p>
<h4>属性均等选择器（Attribute Equals Selector）</h4>
<p><strong>jQuery(&#8216;[attribute=value]&#8216;)</strong> ，只选择属性的值完全相等的元素，如：<strong>jQuery(&#8216;[rel=nofollow]&#8216;)</strong>，则只选择 rel=&#8221;nofollow&#8221; 的元素，差一点都不行！</p>
<h4>属性非等选择器（Attribute Not Equal Selector）</h4>
<p><strong>jQuery(&#8216;[attribute!=value]&#8216;)</strong> ，和 <strong>:not([attr=value])</strong> 的效果一样，用于选择属性不等于某个值的元素，例如 <strong>jQuery(&#8216;[rel!=nofollow]&#8216;)</strong>，所有 rel=&#8221;nofollow&#8221; 的元素都不会被选择。</p>
<h3>按钮选择器（:button Selector）</h3>
<p><strong>jQuery(&#8216;:button&#8217;)</strong> ，所有的 &#60;input type=&#8221;button&#8221;&#62; 和 &#60;button&#62; 元素都会被选择。</p>
<h3>Checkbox 选择器（:checkbox Selector）</h3>
<p><strong>jQuery(&#8216;:checkbox&#8217;)</strong> ，所有的 &#60;input type=&#8221;checkbox&#8221;&#62; 元素都会被选择。</p>
<h3>Checked 选择器（:checked Selector）</h3>
<p><strong>jQuery(&#8216;:checked&#8217;)</strong> ，可以看做是 Checkbox 选择器的补充，用于选择所有已经被勾选的 Checkbox 对象。</p>
<h3>子元素选择器（Child Selector）</h3>
<p><strong>jQuery(&#8216;parent > child&#8217;)</strong>，只选择 parent 的子元素（下一级元素），不对子元素以下的元素进行选择。</p>
<hr />
<p>近期忙，少更新。</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/css-turn-off-webkit-browsers-input-highlight-and-textarea-resize/" title="CSS 屏蔽 Webkit 浏览器 input 高亮和 textarea 缩放">CSS 屏蔽 Webkit 浏览器 input 高亮和 textarea 缩放</a></li><li><a href="http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/" title="利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件">利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</a></li><li><a href="http://blog.imbolo.com/customizing-the-new-wordpress-3-0-custom-menus-adding-different-icons-to-each-link/" title="为 WordPress 3.0 的自定义菜单链接添加栏目图标">为 WordPress 3.0 的自定义菜单链接添加栏目图标</a></li><li><a href="http://blog.imbolo.com/center-multiple-divs-with-css/" title="CSS 多个子框架居中">CSS 多个子框架居中</a></li><li><a href="http://blog.imbolo.com/the-css3-flexible-box-model-2/" title="CSS3 灵活的盒子模型(Flexible Box Module) – 2">CSS3 灵活的盒子模型(Flexible Box Module) – 2</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/jquery-selectors/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</title>
		<link>http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/</link>
		<comments>http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 16:54:00 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[WEB]]></category>

		<guid isPermaLink="false">http://blog.imbolo.com/?p=1870</guid>
		<description><![CDATA[如果我们希望把一个网站的更新事实发布到令一个网站上，最好的方法是通过 RSS 进行转载。如果只是需要简单的对更新的条目做个提示的话，使用 JavaScript 是最可行的方法。]]></description>
			<content:encoded><![CDATA[<p>如果我们希望把一个网站的更新实时发布到令一个网站上，最好的方法是通过 RSS 进行转载。如果只是需要简单的对更新的条目做个提示的话，使用 JavaScript 是最可行的方法。但是通过 JavaScript 解析一个 XML 文档十分麻烦。幸好 Yahoo Pipes 为我们提供了非常好的 RSS to JSON 功能，我们可以先把 RSS 转换成 JSON 再用 JavaScript 进行解析，这样比直接解析 XML 简单得多！</p>
<h3>把 RSS 转换成 JSON</h3>
<p><img src="http://i1001.photobucket.com/albums/af131/bolo1988/yahoopipes.png" alt="雅虎 Pipes" class="alignright" /></p>
<p>首先登录 <a href="http://pipes.yahoo.com">http://pipes.yahoo.com</a> ，新建一个 Pipe ( Creat a Pipe ) 。然后在左边的工具里选择 <strong>Sources > Fetch Feed</strong> ，在输入框里输入一个 RSS 地址。再用线把 Fetch Feed 和 Pipe Output 两个框框连起来（如右图），保存这个 Pipe，然后点击顶部的 <strong>Run Pipe&#8230;</strong> 。点击 <strong>Publish</strong> 发布这个 Pipe ，然后记下 <strong>Get as JSON 的 URL</strong>。简单几步就已经把一个 RSS 转换成 JSON 了，而且这个 JSON 会根据 RSS 的更新自动更新。<span id="more-1870"></span></p>
<h3>通过 jQuery 解析 JSON</h3>
<p>jQuery 本身为我们提供了一个 <strong>getJSON()</strong> 函数，为我们解析 JSON 提供简单快捷的方法。</p>
<p>由于我希望做一个 AJAX 载入项目的效果，我先做一个 HTML 框架，然后通过 jQuery 的 append 方法把解析出来的内容添加到指定的容器里。HTML框架如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="html4strick" style="font-family:monospace;">&lt;div id=&quot;rssdata&quot;&gt;
	&lt;ul class=&quot;rss-items&quot;&gt;&lt;/ul&gt;
	&lt;div class=&quot;loading&quot;&gt;Loading RSS items...&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;然后编写 jQuery 调用：&lt;/p&gt;</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#rssdata'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// JSON 地址 = 刚才记下的 URL + &amp;_callback=?</span>
	<span style="color: #003366; font-weight: bold;">var</span> pipe_url <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://pipes.yahoo.com/pipes/pipe.run?_id=90caf3b6ba8f36459a3137248b47620e&amp;_render=json&amp;_callback=?'</span><span style="color: #339933;">;</span>
&nbsp;
	$.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span>pipe_url<span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// 遍历 JSON 项目，并且确定输出哪些信息</span>
		$<span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">value</span>.<span style="color: #660066;">items</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> item_html <span style="color: #339933;">=</span> <span style="color: #3366CC;">'&lt;li&gt;&lt;a href=&quot;'</span><span style="color: #339933;">+</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">link</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot;&gt;'</span><span style="color: #339933;">+</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">title</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #006600; font-style: italic;">// 把输出的内容插入页面里</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#rssdata ul.rss-items'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span>item_html<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">// 添加条目载入效果</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#rssdata div.loading'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#rssdata ul.rss-items'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>当然要页面美观的话，写一些 CSS 是必要的，这个可以随自己的喜好而定。最终的效果可以看这个 <a href='http://blog.imbolo.com/wp-content/uploads/2010/06/rss_widget.html'>DEMO</a>。</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/jquery-jwtabs/" title="jQuery插件：jwTabs">jQuery插件：jwTabs</a></li><li><a href="http://blog.imbolo.com/make-a-jquery-style-switch/" title="用jQuery制作页面风格切换开关">用jQuery制作页面风格切换开关</a></li><li><a href="http://blog.imbolo.com/make-ajax-with-jquery/" title="使用 jQuery 简化 Ajax 开发">使用 jQuery 简化 Ajax 开发</a></li><li><a href="http://blog.imbolo.com/make-a-door-effect-in-jquery-and-css/" title="jQuery+CSS制作滑动门效果">jQuery+CSS制作滑动门效果</a></li><li><a href="http://blog.imbolo.com/jquery-make-the-link-background-fadein-effect/" title="jQuery实现链接背景淡出淡入效果">jQuery实现链接背景淡出淡入效果</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>动态调整图片尺寸</title>
		<link>http://blog.imbolo.com/dynamic-image-resize-via-jquery-javascript/</link>
		<comments>http://blog.imbolo.com/dynamic-image-resize-via-jquery-javascript/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 10:23:19 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.imbolo.com/?p=1489</guid>
		<description><![CDATA[在自己的网站上更新文章时一个比较常见的问题是：文章插图太宽，使整个网页都变形了。如果对每个插图都先进行缩放再插入的话，太麻烦了。
我前段时间写的一篇文章就遇到过这种事情，后来用CSS的overflow和max-width属性暂时解决了页面变形的问题。这种方法好处是简单，但坏处是会破坏某些细节的效果。]]></description>
			<content:encoded><![CDATA[<p>在自己的网站上更新文章时一个比较常见的问题是：文章插图太宽，使整个网页都变形了。如果对每个插图都先进行缩放再插入的话，太麻烦了。<br />
我前段时间写的一篇文章就遇到过这种事情，后来用CSS的overflow和max-width属性暂时解决了页面变形的问题。这种方法好处是简单，但坏处是会破坏某些细节的效果。<span id="more-1489"></span><br />
如overflow：hidden，意思是当内部元素宽度大于父框架时隐藏超出宽度的部分。这样做可能会是一些内容突然截断，被隐藏了，很对不起观众。<br />
通过max-width属性限制文章插图最大宽度的话，需要考虑各浏览器的兼容性。IE6是不支持这个属性的，在我印象中，一些浏览器虽然支持这个属性，但图片不是等比缩放的（好像是Safari和Opera，记不清了），这样做的话对这些浏览器的用户很不公平。<br />
因此，我最终选择的是通过JavaScript动态改变图片尺寸。这种方法对各种浏览器兼容性良好（现在应该很少人会禁用JavaScript吧？），如果换主题的话，也可以灵活地改变文章插图的最大尺寸。<br />
方案有两个，由于我使用的主题是加载了jQuery库的，因此可以用以下代码实现：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.post img'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> maxWidth <span style="color: #339933;">=</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 图片最大宽度</span>
    <span style="color: #003366; font-weight: bold;">var</span> maxHeight <span style="color: #339933;">=</span> <span style="color: #CC0000;">100</span><span style="color: #339933;">;</span>    <span style="color: #006600; font-style: italic;">// 图片最大高度</span>
    <span style="color: #003366; font-weight: bold;">var</span> ratio <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">// 缩放比例</span>
    <span style="color: #003366; font-weight: bold;">var</span> width <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #006600; font-style: italic;">// 图片实际宽度</span>
    <span style="color: #003366; font-weight: bold;">var</span> height <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">// 图片实际高度</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// 检查图片是否超宽</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>width <span style="color: #339933;">&gt;</span> maxWidth<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        ratio <span style="color: #339933;">=</span> maxWidth <span style="color: #339933;">/</span> width<span style="color: #339933;">;</span>   <span style="color: #006600; font-style: italic;">// 计算缩放比例</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">,</span> maxWidth<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 设定实际显示宽度</span>
        height <span style="color: #339933;">=</span> height <span style="color: #339933;">*</span> ratio<span style="color: #339933;">;</span>    <span style="color: #006600; font-style: italic;">// 计算等比例缩放后的高度 </span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;height&quot;</span><span style="color: #339933;">,</span> height <span style="color: #339933;">*</span> ratio<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">// 设定等比例缩放后的高度</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// 检查图片是否超高</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>height <span style="color: #339933;">&gt;</span> maxHeight<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        ratio <span style="color: #339933;">=</span> maxHeight <span style="color: #339933;">/</span> height<span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// 计算缩放比例</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;height&quot;</span><span style="color: #339933;">,</span> maxHeight<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #006600; font-style: italic;">// 设定实际显示高度</span>
        width <span style="color: #339933;">=</span> width <span style="color: #339933;">*</span> ratio<span style="color: #339933;">;</span>    <span style="color: #006600; font-style: italic;">// 计算等比例缩放后的高度</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">,</span> width <span style="color: #339933;">*</span> ratio<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #006600; font-style: italic;">// 设定等比例缩放后的高度</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>如果不想加载jQuery库，可以用以下代码：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> ResizeImage<span style="color: #009900;">&#40;</span>image<span style="color: #339933;">,</span> 插图最大宽度<span style="color: #339933;">,</span> 插图最大高度<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>image.<span style="color: #660066;">className</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;Thumbnail&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        w <span style="color: #339933;">=</span> image.<span style="color: #660066;">width</span><span style="color: #339933;">;</span>
        h <span style="color: #339933;">=</span> image.<span style="color: #660066;">height</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> w <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span> <span style="color: #339933;">||</span> h <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            image.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> maxwidth<span style="color: #339933;">;</span>
            image.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> maxheight<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>w <span style="color: #339933;">&gt;</span> h<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>w <span style="color: #339933;">&gt;</span> maxwidth<span style="color: #009900;">&#41;</span> image.<span style="color: #660066;">width</span> <span style="color: #339933;">=</span> maxwidth<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">else</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;</span> maxheight<span style="color: #009900;">&#41;</span> image.<span style="color: #660066;">height</span> <span style="color: #339933;">=</span> maxheight<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        image.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;ScaledThumbnail&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>采用纯JavaScript的话，麻烦点，需要手动为图片加上class=&#8221;Thumbnail&#8221;，但最终效果是一样的。</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/jquery-selectors/" title="jQuery选择器详解（一）">jQuery选择器详解（一）</a></li><li><a href="http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/" title="利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件">利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</a></li><li><a href="http://blog.imbolo.com/set-paragraph-spacing-with-css/" title="CSS 设置段落间距">CSS 设置段落间距</a></li><li><a href="http://blog.imbolo.com/jquery-jwtabs/" title="jQuery插件：jwTabs">jQuery插件：jwTabs</a></li><li><a href="http://blog.imbolo.com/make-a-jquery-style-switch/" title="用jQuery制作页面风格切换开关">用jQuery制作页面风格切换开关</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/dynamic-image-resize-via-jquery-javascript/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>jQuery插件：jwTabs</title>
		<link>http://blog.imbolo.com/jquery-jwtabs/</link>
		<comments>http://blog.imbolo.com/jquery-jwtabs/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 05:48:03 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WEB]]></category>

		<guid isPermaLink="false">http://blog.imbolo.com/?p=1487</guid>
		<description><![CDATA[jwTabs是Jeffrey制作的一个基于jQuery的Tab插件，与比较出名的idTab相比，它具有以下优点]]></description>
			<content:encoded><![CDATA[<p>jwTabs是<a href="http://jeffrey-way.com" rel="external">Jeffrey</a>制作的一个基于jQuery的Tab插件，与比较出名的idTab相比，它具有以下优点：</p>
<blockquote><p>
   1. 可以自由选择过渡效果<br />
   2. 可以自动切换Tab<br />
   3. 插件大小只有1K<br />
   4. Has everything you’d actually use…and nothing more.（怎么翻译？）<br />
   5. 不需要对代码进行特殊标记
</p></blockquote>
<p>插件的主页是：<a href="http://jeffrey-way.com/projects/introducing-jwtabs/" rel="external">Introducing jwTabs</a><span id="more-1487"></span></p>
<h5>例子：</h5>
<p>假设你需要对以下代码进行Tab处理：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="html4strick" style="font-family:monospace;">&lt;div id=&quot;tab-container&quot;&gt;
 	&lt;div&gt;
		&lt;h2&gt;1st tab&lt;/h2&gt;
		&lt;p&gt; .......&lt;/p&gt;
	&lt;/div&gt;
&nbsp;
	&lt;div&gt;
		&lt;h2&gt;2nd tab&lt;/h2&gt;
		&lt;p&gt;......&lt;/p&gt;			
	&lt;/div&gt;
&nbsp;
	&lt;div&gt;
		&lt;h2&gt;3rd tab&lt;/h2&gt;
		&lt;p&gt;......&lt;/p&gt;			
		&lt;p&gt;......&lt;/p&gt;			
		&lt;p&gt;......&lt;/p&gt;						
	&lt;/div&gt;	
&nbsp;
 	&lt;div&gt;
		&lt;h2&gt;4th tab&lt;/h2&gt;
		&lt;p&gt;......&lt;/p&gt;
	&lt;/div&gt;
&nbsp;
 	&lt;div&gt;
		&lt;h2&gt;5th tab&lt;/h2&gt;
		&lt;p&gt;......&lt;/p&gt;
	&lt;/div&gt;
&nbsp;
 	&lt;div&gt;
		&lt;h2&gt;6th tab&lt;/h2&gt;
		&lt;p&gt;......&lt;/p&gt;
	&lt;/div&gt;				
 &lt;/div&gt;</pre></td></tr></table></div>

<p>你不需要对HTML再作任何处理，只需要添加以下脚本：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">jQuery<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#tab-container'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">jwTabs</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	interval <span style="color: #339933;">:</span> <span style="color: #CC0000;">6000</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//自动切换Tab的时间间隔，单位ms</span>
	startTab <span style="color: #339933;">:</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span><span style="color: #006600; font-style: italic;">//默认显示的Tab序号</span>
	tabTitleReference <span style="color: #339933;">:</span> <span style="color: #3366CC;">'h2'</span><span style="color: #006600; font-style: italic;">//Tab标签的标题</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>DEMO：<a href="http://jeffrey-way.s3.amazonaws.com/015_jwTabs/jwTabs/index.html" rel="external">http://jeffrey-way.s3.amazonaws.com/015_jwTabs/jwTabs/index.html</a></p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/" title="利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件">利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</a></li><li><a href="http://blog.imbolo.com/make-a-jquery-style-switch/" title="用jQuery制作页面风格切换开关">用jQuery制作页面风格切换开关</a></li><li><a href="http://blog.imbolo.com/make-ajax-with-jquery/" title="使用 jQuery 简化 Ajax 开发">使用 jQuery 简化 Ajax 开发</a></li><li><a href="http://blog.imbolo.com/make-a-door-effect-in-jquery-and-css/" title="jQuery+CSS制作滑动门效果">jQuery+CSS制作滑动门效果</a></li><li><a href="http://blog.imbolo.com/jquery-make-the-link-background-fadein-effect/" title="jQuery实现链接背景淡出淡入效果">jQuery实现链接背景淡出淡入效果</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/jquery-jwtabs/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>用jQuery制作页面风格切换开关</title>
		<link>http://blog.imbolo.com/make-a-jquery-style-switch/</link>
		<comments>http://blog.imbolo.com/make-a-jquery-style-switch/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 12:43:44 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WEB]]></category>

		<guid isPermaLink="false">http://digau.cn/?p=1238</guid>
		<description><![CDATA[越来越多网站已经通过让访客自己选择页面风格来提高访客体验。这次我们利用jQuery这把锋利的剑来实现这个功能。
首先，在header加入几个风格链接是必须的。]]></description>
			<content:encoded><![CDATA[<p>越来越多网站已经通过让访客自己选择页面风格来提高访客体验。这次我们利用jQuery这把锋利的剑来实现这个功能。<br />
首先，在header加入几个风格链接是必须的。</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">&lt;link rel<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;styles1.css&quot;</span> title<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;styles1&quot;</span> media<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span> /<span style="color: #00AA00;">&gt;</span>
<span style="color: #808080; font-style: italic;">/*记得为候选风格加上rel=&quot;alternate&quot;，否则会引起冲突*/</span>
&lt;link rel<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;alternate stylesheet&quot;</span> type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;styles2.css&quot;</span> title<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;styles2&quot;</span> media<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span> /<span style="color: #00AA00;">&gt;</span>
&lt;link rel<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;alternate stylesheet&quot;</span> type<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> href<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;styles3.css&quot;</span> title<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;styles3&quot;</span> media<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span> /<span style="color: #00AA00;">&gt;</span></pre></div></div>

<p>接下来在页面里加上开关链接，按下面的格式写</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;serversideSwitch.html?style=style1&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;styles1&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;styleswitch&quot;</span>&gt;</span>styles1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;serversideSwitch.html?style=style2&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;styles2&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;styleswitch&quot;</span>&gt;</span>styles2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;serversideSwitch.html?style=style3&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;styles3&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;styleswitch&quot;</span>&gt;</span>styles3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></div></div>

<p><span id="more-1238"></span>最后进行最关键的一部分，写脚本</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.styleswitch'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			switchStylestyle<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;rel&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> readCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> switchStylestyle<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> switchStylestyle<span style="color: #009900;">&#40;</span>styleName<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'link[@rel*=style][title]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> 
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> styleName<span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">disabled</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		createCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'style'</span><span style="color: #339933;">,</span> styleName<span style="color: #339933;">,</span> <span style="color: #CC0000;">365</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//把风格设置记录到cookie，并设置失效时间</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//创建cookie</span>
<span style="color: #003366; font-weight: bold;">function</span> createCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #339933;">,</span>value<span style="color: #339933;">,</span>days<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>days<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> date <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		date.<span style="color: #660066;">setTime</span><span style="color: #009900;">&#40;</span>date.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span>days<span style="color: #339933;">*</span><span style="color: #CC0000;">24</span><span style="color: #339933;">*</span><span style="color: #CC0000;">60</span><span style="color: #339933;">*</span><span style="color: #CC0000;">60</span><span style="color: #339933;">*</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> expires <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;; expires=&quot;</span><span style="color: #339933;">+</span>date.<span style="color: #660066;">toGMTString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #003366; font-weight: bold;">var</span> expires <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
	document.<span style="color: #660066;">cookie</span> <span style="color: #339933;">=</span> <span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #339933;">+</span>value<span style="color: #339933;">+</span>expires<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;; path=/&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//读取cookie</span>
<span style="color: #003366; font-weight: bold;">function</span> readCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> nameEQ <span style="color: #339933;">=</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> ca <span style="color: #339933;">=</span> document.<span style="color: #660066;">cookie</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">';'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i <span style="color: #339933;">&lt;</span> ca.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> ca<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span> c <span style="color: #339933;">=</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span>c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>nameEQ<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>nameEQ.<span style="color: #660066;">length</span><span style="color: #339933;">,</span>c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//清除cookie</span>
<span style="color: #003366; font-weight: bold;">function</span> eraseCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	createCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>好了，想熟悉的话，自己动手，由于时间关系，我没有做DEMO，请谅解。</p>
<p>原文链接：<a href="http://www.kelvinluck.com/2006/05/switch-stylesheets-with-jquery/" rel="external nofollow">http://www.kelvinluck.com/2006/05/switch-stylesheets-with-jquery/</a></pre>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/" title="利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件">利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</a></li><li><a href="http://blog.imbolo.com/jquery-jwtabs/" title="jQuery插件：jwTabs">jQuery插件：jwTabs</a></li><li><a href="http://blog.imbolo.com/make-ajax-with-jquery/" title="使用 jQuery 简化 Ajax 开发">使用 jQuery 简化 Ajax 开发</a></li><li><a href="http://blog.imbolo.com/make-a-door-effect-in-jquery-and-css/" title="jQuery+CSS制作滑动门效果">jQuery+CSS制作滑动门效果</a></li><li><a href="http://blog.imbolo.com/jquery-make-the-link-background-fadein-effect/" title="jQuery实现链接背景淡出淡入效果">jQuery实现链接背景淡出淡入效果</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/make-a-jquery-style-switch/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>使用 jQuery 简化 Ajax 开发</title>
		<link>http://blog.imbolo.com/make-ajax-with-jquery/</link>
		<comments>http://blog.imbolo.com/make-ajax-with-jquery/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 00:16:59 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WEB]]></category>

		<guid isPermaLink="false">http://digau.cn/?p=967</guid>
		<description><![CDATA[jQuery 是一个JavaScript 库，它有助于简化 JavaScript™ 以及 Asynchronous JavaScript + XML (Ajax) 编程。与类似的 JavaScript 库不同，jQuery 具有独特的基本原理，可以简洁地表示常见的复杂代码。学习 jQuery 基本原理，探索其特性和功能，执行一些常见的 Ajax 任务并掌握如何使用插件扩展 jQuery。]]></description>
			<content:encoded><![CDATA[<p>jQuery 是一个JavaScript 库，它有助于简化 JavaScript™ 以及 Asynchronous JavaScript + XML (Ajax) 编程。与类似的 JavaScript 库不同，jQuery 具有独特的基本原理，可以简洁地表示常见的复杂代码。学习 jQuery 基本原理，探索其特性和功能，执行一些常见的 Ajax 任务并掌握如何使用插件扩展 jQuery。</p>
<p><strong>jQuery 是什么？</strong></p>
<p>jQuery 由 John Resig 创建于 2006 年初，对于任何使用 JavaScript 代码的程序员来说，它是一个非常有用的 JavaScript 库。无论您是刚刚接触 JavaScript 语言，并且希望获得一个能解决文档对象模型（Document Object Model，DOM）脚本和 Ajax 开发中一些复杂问题的库，还是作为一个厌倦了 DOM 脚本和 Ajax 开发中无聊的重复工作的资深 JavaScript 专家，jQuery 都会是您的首选。</p>
<p>jQuery 能帮助您保证代码简洁易读。您再也不必编写大堆重复的循环代码和 DOM 脚本库调用了。使用 jQuery，您可以把握问题的要点，并使用尽可能最少的代码实现您想要的功能。</p>
<p>毫无疑问，jQuery 的原理是独一无二的：它的目的就是保证代码简洁并可重用。当您理解并体会这一原理后，便可以开始学习本教程了，看看 jQuery 对我们的编程方式有多少改进吧。</p>
<p><span id="more-967"></span><strong>一些简单的代码简化</strong><br />
下面是一个简单示例，它说明了 jQuery 对代码的影响。要执行一些真正简单和常见的任务，比方说为页面的某一区域中的每个链接附加一个单击（click）事件，您可以使用纯 JavaScript 代码和 DOM 脚本来实现，如 清单 1 所示。<br />
<strong>清单 1. 没有使用 jQuery 的 DOM 脚本</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> external_links <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'external_links'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> links <span style="color: #339933;">=</span> external_links.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> links.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> link <span style="color: #339933;">=</span> links.<span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    link.<span style="color: #660066;">onclick</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066;">confirm</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'You are going to visit: '</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">href</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>清单 2 显示了使用 jQuery 实现的相同的功能。<br />
<strong>清单 2. 使用了 jQuery 的 DOM 脚本</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#external_links a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066;">confirm</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'You are going to visit: '</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">href</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>是不是很神奇？ 使用 jQuery，您可以把握问题的要点，只让代码实现您想要的功能，而省去了一些繁琐的过程。无需对元素进行循环，click() 函数将完成这些操作。同样也不需要进行多个 DOM 脚本调用。您只需要使用一个简短的字符串对所需的元素进行定义即可。</p>
<p>理解这一代码的工作原理可能会有一点复杂。首先，我们使用了 $() 函数 —— jQuery 中功能最强大的函数。通常，我们都是使用这个函数从文档中选择元素。在本例中，一个包含有一些层叠样式表（Cascading Style Sheet，CSS）语法的字符串被传递给函数，然后 jQuery 尽可能高效地把这些元素找出来。</p>
<p>如果您具备 CSS 选择器的基本知识，那么应该很熟悉这些语法。在 清单 2 中，#external_links 用于检索 id 为 external_links 的元素。a 后的空格表示 jQuery 需要检索 external_links 元素中的所有&#60;&#97;&#62;元素。用英语说起来非常绕口，甚至在 DOM 脚本中也是这样，但是在 CSS 中这再简单不过了。</p>
<p>$() 函数返回一个含有所有与 CSS 选择器匹配的元素的 jQuery 对象。jQuery 对象 类似于数组，但是它附带有大量特殊的 jQuery 函数。比方说，您可以通过调用 click 函数把 click 处理函数指定给 jQuery 对象中的所有元素。</p>
<p>还可以向 $() 函数传递一个元素或者一个元素数组，该函数将把这些元素封装在一个 jQuery 对象中。您可能会想要使用这个功能将 jQuery 函数用于一些对象，比方说 window 对象。例如，我们通常会像下面这样把函数分配给加载事件：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// do this stuff when the page is done loading</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>使用 jQuery 编写的功能相同的代码：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// run this when the whole page has been downloaded</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>您可能有所体会，等待窗口加载的过程是非常缓慢而且令人痛苦的，这是因为必须等整个页面加载完所有的内容，包括页面上所有的的图片。有的时候，您希望首先完成图片加载，但是在大多数情况下，您只需加载超文本标志语言（Hypertext Markup Language，HTML）就可以了。通过在文档中创建特殊的 ready 事件，jQuery 解决了这个问题，方法如下：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// do this stuff when the HTML is all ready</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>这个代码围绕 document 元素创建了一个 jQuery 对象，然后建立一个函数，用于在 HTML DOM 文档就绪的时候调用实例。可以根据需要任意地调用这个函数。并且能够以真正的 jQuery 格式，使用快捷方式调用这个函数。这很简单，只需向 $() 函数传递一个函数就可以了：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// run this when the HTML is done downloading</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>到目前以止，我已经向大家介绍了 $() 函数的三种用法。第四种方法可以使用字符串来创建元素。结果会产生一个包含该元素的 jQuery 对象。清单 3 显示的示例在页面中添加了一个段落。</p>
<p><strong>清单 3. 创建和附加一个简单的段落</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'
&nbsp;
'</span><span style="color: #009900;">&#41;</span>
    .<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Hey World!'</span><span style="color: #009900;">&#41;</span>
    .<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'background'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yellow'</span><span style="color: #009900;">&#41;</span>
    .<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>在前一个例子中您可能已经注意到，jQuery 中的另一个功能强大的特性就是方法链接（method chaining）。每次对 jQuery 对象调用方法时，方法都会返回相同的 jQuery 对象。这意味着如果您需要对 jQuery 对象调用多个方法，那么您不必重新键入选择器就可以实现这一目的：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#message'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'background'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yellow'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Hello!'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>使 Ajax 变得简单</strong><br />
使用 jQuery 将使 Ajax 变得及其简单。jQuery 提供有一些函数，可以使简单的工作变得更加简单，复杂的工作变得不再复杂。<br />
Ajax 最常见的用法就是把一块 HTML 代码加载到页面的某个区域中去。为此，只需简单地选择所需的元素，然后使用 load() 函数即可。下面是一个用于更新统计信息的示例：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#stats'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'stats.html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>通常，我们只需简单地把一些参数传递给服务器中的某个页面。正如您所预料的，使用 jQuery 实现这一操作非常地简单。您可以使用 $.post() 或者 $.get()，这由所需的方法决定。如果需要的话，您还可以传递一个可选的数据对象和回调函数。清单 4 显示了一个发送数据和使用回调的简单示例。</p>
<p><strong>清单 4. 使用 Ajax 向页面发送数据</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'save.cgi'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
    text<span style="color: #339933;">:</span> <span style="color: #3366CC;">'my string'</span><span style="color: #339933;">,</span>
    number<span style="color: #339933;">:</span> <span style="color: #CC0000;">23</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Your data has been saved.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>如果您确实需要编写一些复杂的 Ajax 脚本，那么需要用到 $.ajax() 函数。您可以指定 xml、script、html 或者 json，jQuery 将自动为回调函数准备合适的结果，这样您便可以立即使用该结果。还可以指定 beforeSend、error、success 或者 complete 回调函数，向用户提供更多有关 Ajax 体验的反馈。此外，还有一些其它的参数可供使用，您可以使用它们设置 Ajax 请求的超时，也可以设置页面 “最近一次修改” 的状态。清单 5 显示了一个使用一些我所提到的参数检索 XML 文档的示例。</p>
<p><strong>清单 5. $.ajax() 使 Ajax 由复杂变简单</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'document.xml'</span><span style="color: #339933;">,</span>
    type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'GET'</span><span style="color: #339933;">,</span>
    dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">'xml'</span><span style="color: #339933;">,</span>
    timeout<span style="color: #339933;">:</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">,</span>
    error<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Error loading XML document'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>xml<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// do something with xml</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>当 success 回调函数返回 XML 文档后，您可以使用 jQuery 检索这个 XML 文档，其方式与检索 HTML 文档是一样的。这样使得处理 XML 文档变得相当地容易，并且把内容和数据集成到了您的 Web 站点里面。清单 6 显示了 success 函数的一个扩展，它为 XML 中的每个 元素都添加了一个列表项到 Web 页面中。</p>
<p><strong>清单 6. 使用 jQuery 处理 XML 文档</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>xml<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span>xml<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'item'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> item_text <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'
	&lt;li&gt;
&nbsp;
'</span><span style="color: #009900;">&#41;</span>
            .<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>item_text<span style="color: #009900;">&#41;</span>
            .<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ol'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span></pre></div></div>

<p><strong>为 HTML 添加动画</strong></p>
<p>可以使用 jQuery 处理基本的动画和显示效果。animate() 函数是动画代码的核心，它用于更改任何随时间变化的数值型的 CSS 样式值。比方说，您可以变化高度、宽度、不透明度和位置。还可以指定动画的速度，定为毫秒或者预定义的速度：慢速，中速或快速。<br />
下面是一个同时变化某个元素高度和宽度的示例。请注意，这些参数没有开始值，只有最终值。开始值取自元素的当前尺寸。同时我也附加了一个回调函数。</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#grow'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> height<span style="color: #339933;">:</span> <span style="color: #CC0000;">500</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span> <span style="color: #CC0000;">500</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'The element is done growing!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>jQuery 的内置函数使更多常见的动画更容易完成。可以使用 show() 和 hide() 元素，立即显示或者以特定的速度显示。还可以通过使用 fadeIn() 和 fadeOut()，或者 slideDown() 和 slideUp() 显示和隐藏元素，这取决于您所需要的显示效果。下面的示例定义了一个下滑的导航菜单。</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#nav'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>DOM 脚本和事件处理</strong></p>
<p>或许 jQuery 最擅长的就是简化 DOM 脚本和事件处理。遍历和处理 DOM 非常简单，同时附加、移除和调用事件也十分容易，且不像手动操作那样容易出错。<br />
从本质上说，jQuery 可以使 DOM 脚本中的常用操作变得更加容易。您可以创建元素并且使用 append() 函数把它们与其它的一些元素链接到一起，使用 clone() 复制元素，使用 html() 设置内容，使用 empty() 函数删除内容，使用 remove() 函数删除所有的元素，即便是使用 wrap() 函数，用其他元素将这些元素包装起来。<br />
通过遍历 DOM，一些函数可以用于更改 jQuery 对象本身的内容。可以获得元素所有的 siblings()、parents() 和 children()。还可以选择 next() 和 prev() 兄弟元素。find() 函数或许是功能最强大的函数，它允许使用 jQuery 选择器搜索 jQuery 对象中元素的后代元素。<br />
如果结合使用 end() 函数，那么这些函数将变得更加强大。这个函数的功能类似于 undo 函数，用于返回到调用 find() 或 parents() 函数（或者其它遍历函数）之前的 jQuery 对象。<br />
如果配合方法链接（method chaining）一起使用，这些函数可以使复杂的操作看上去非常简单。清单 7 显示了一个示例，其中包含有一个登录表单并处理了一些与之有关的元素。</p>
<p><strong>清单 7. 轻松地遍历和处理 DOM</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'form#login'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #006600; font-style: italic;">// hide all the labels inside the form with the 'optional' class</span>
    .<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'label.optional'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// add a red border to any password fields in the form</span>
    .<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input:password'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'border'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'1px solid red'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">end</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// add a submit handler to the form</span>
    .<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066;">confirm</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Are you sure you want to submit?'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>不管您是否相信，这个示例只是一行满是空白的被链接的代码。首先，选择登录表单。然后，发现其中含有可选标签，隐藏它们，并调用 end() 返回表单。然后，我创建了密码字段，将其边界变为红色，再次调用 end() 返回表单。最后，我在表单中添加了一个提交事件处理程序。其中尤为有趣的就是（除了其简洁性以外），jQuery 完全优化了所有的查询操作，确保将所有内容很好地链接在一起后，不需要对一个元素执行两次查询。<br />
处理常见事件就像调用函数（比方说 click()、submit() 或 mouseover()）和为其传递事件处理函数一样简单。此外，还可以使用 bind(&#8216;eventname&#8217;, function(){}) 指定自定义的事件处理程序。可以使用 unbind(&#8216;eventname&#8217;) 删除某些事件或者使用 unbind() 删除所有的事件。有关这些函数的使用方法的完整列表，请参阅 参考资料 中的 jQuery 应用程序编程接口（Application Program Interface，API）文档。</p>
<p><strong>释放 jQuery 选择器的强大能量</strong><br />
我们经常会使用 ID 来选择元素，比如 #myid，或者通过类名，比如 div.myclass 来选择元素。然而，jQuery 提供了更为复杂和完整的选择器语法，允许我们在单个选择器中选择几乎所有的元素组合。<br />
jQuery 的选择器语法主要是基于 CSS3 和 XPath 的。对 CSS3 和 XPath 了解的越多，使用 jQuery 时就越加得心应手。有关 jQuery 选择器的完整列表，包括 CSS 和 XPath，请参阅 参考资料 中的链接。<br />
CSS3 包含一些并不是所有浏览器都支持的语法，因此我们很少使用它。然而，我们仍然可以在 jQuery 中使用 CSS3 选择元素，因为 jQuery 具备自己的自定义选择器引擎。比方说，要在表格中的每一个空列中都添加一个横杠，可以使用：:empty 伪选择器（pseudo-selector）：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'td:empty'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'-'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>如果需要找出所有不含特定类的元素呢？ CSS3 同样提供了一个语法可以完成这个目的，使用 :not 伪选择器： 如下代码显示了如何隐藏所有不含 required 类的输入内容：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input:not(.required)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>与在 CSS 中一样，可以使用逗号将多个选择器连接成一个。下面是一个同时隐藏页面上所有类型列表的简单示例：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul, ol, dl'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>XPath 是一种功能强大的语法，用于在文档中搜寻元素。它与 CSS 稍有区别，不过它能实现的功能略多于 CSS。要在所有复选框的父元素中添加一个边框，可以使用 XPath 的 /.. 语法：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input:checkbox/..&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'border'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'1px solid #777'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>jQuery 中也加入了一些 CSS 和 XPath 中没有的选择器。比方说，要使一个表更具可读性，通常可以在表格的奇数行或偶数行中附加一个不同的类名 —— 也可以称作把表分段（striping）。使用 jQuery 不费吹灰之力就可以做到这点，这需要归功于 odd 伪选择器。下面这个例子使用 striped 类改变了表格中所有奇数行的背景颜色：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'table.striped &amp;gt; tr:odd'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'background'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#999999'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>我们可以看到强大的 jQuery 选择器是如何简化代码的。不论您想处理什么样的元素，不管这个元素是具体的还是模糊的，都有可能找到一种方法使用一个 jQuery选择器对它们进行定义。</p>
<p><strong>使用插件扩展 jQuery</strong></p>
<p>与大多数软件不同，使用一个复杂的 API 为 jQuery 编写插件并不是非常困难。事实上，jQuery 插件非常易于编写，您甚至希望编写一些插件来使代码更加简单。下面是可以编写的最基本的 jQuery 插件：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">donothing</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>虽然非常简单，但是还是需要对这个插件进行一些解释。首先，如果要为每一个 jQuery 对象添加一个函数，必须把该函数指派给 $.fn。第二，这个函数必须要返回一个 this（jQuery 对象），这样才不至于打断 方法链接（method chaining）。<br />
可以轻松地在这个示例之上构建。要编写一个更换背景颜色的插件，以替代使用 css(&#8216;background&#8217;)，可以使用下面的代码：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">background</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>bg<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'background'</span><span style="color: #339933;">,</span> bg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>清注意，可以只从 css() 返回值，因为已经返回了 jQuery 对象。因此，方法链接（method chaining）仍然运作良好。<br />
我建议在需要重复工作的时候使用 jQuery 插件。比方说，如果您需要使用 each() 函数反复执行相同的操作，那么可以使用一个插件来完成。<br />
由于 jQuery 插件相当易于编写，所以有上百种可供你选择使用。jQuery 提供的插件可用于制表、圆角、滑动显示、工具提示、日期选择器，以及我们可以想到的一切效果。有关插件的完整列表，请参阅 参考资料。<br />
最为复杂、使用最为广泛的插件要属界面（Interface），它是一种动画插件，用于处理排序、拖放功能、复杂效果、以及其它有趣和复杂的用户界面（User Interface，UI）。界面对于 jQuery 来说就如 Scriptaculous 对于 Prototype 一样。<br />
表单插件也同样流行且非常有用，通过它可以使用 Ajax 在后台中轻松地提交表单。这个插件用于处理一些常见的情况：您需要截获某个表单的提交事件，找出所有不同的输入字段，并使用这些字段构造一个 Ajax 调用。</p>
<p><strong>结束语</strong></p>
<p>我只是简要地介绍了使用 jQuery 可能完成的任务。jQuery 使用起来非常有趣，因此我们总是能学到看上去很简单的新技巧和新特性。从刚开始使用 jQuery 的那一刻起，jQuery 便可以完全简化您的 JavaScript 和 Ajax 编程；每学会一点新知识，您的代码就会更简单一点。<br />
学习了 jQuery 之后，我在使用 JavaScript 语言进行编程的同时也获得了许多的乐趣。不用操心所有无聊的内容，我可以专注地编写有趣的内容。使用 jQuery 后，我几乎就告别了编写 for 循环代码的时代。甚至在想到要使用其它 JavaScript 库时，不禁会有所畏缩不前。jQuery 确确实实改变了我对 JavaScript 编程的看法。</p>
<p><strong>参考资料</strong></p>
<p><strong>学习</strong><br />
	您可以参阅本文在 developerWorks 全球网站上的 <a href="http://www.ibm.com/developerworks/xml/library/x-ajaxjquery.html?S_TACT=105AGX52&amp;S_CMP=cn-a-x" target="_blank">英文原文</a>。<br />
	<a href="http://www.ibm.com/developerworks/cn/ajax/" target="_blank"> Ajax 技术资源中心</a>：developerWorks 上所有有关 Ajax 的问题都可以在这里找到解答。<br />
	<a href="http://www.ibm.com/developerworks/cn/xml" target="_blank">developerWork 中国网站 XML 专区</a>：了解 XML 的方方面面。<br />
	<a href="http://docs.jquery.com/Main_Page" target="_blank">jQuery API 文档</a>：通过一些教程和 API 参考资料的链接，研究完整的 jQuery 的文档。<br />
	<a href="http://docs.jquery.com/Tutorials" target="_blank">jQuery 教程</a>：参阅各种不同语言的 jQuery 教程，包括 40 篇英语文章。<br />
	<a href="http://visualjquery.com/" target="_blank">可视化 jQuery</a>：阅读这个交互式的、易于导航的 jQuery API 参考资料。<br />
	<a href="http://www.ibm.com/certify/certs/xmsdreltop.shtml?S_TACT=105AGX52&amp;S_CMP=cn-a-x" target="_blank">IBM XML 认证</a>：看看如何才能成为一名 IBM 认证的 XML 及相关技术的开发人员。<br />
	<a href="http://www.ibm.com/developerworks/cn/xml/library/technical/xml.html" target="_blank">XML 技术文档库</a>：developerWorks XML 专区提供了大量技术文章、提示、教程、标准以及 IBM 红皮书。</p>
<p><strong>获得产品和技术</strong></p>
<ul>
	<a href="http://jquery.com/" target="_blank">jQuery</a>：访问 jQuery 主页并下载源代码。<br />
	<a href="http://docs.jquery.com/DOM/Traversing/Selectors" target="_blank">选择器</a>：获取在 jQuery 中可以使用的选择器的完整列表，包括 CSS3 和 XPath 选择器。<br />
	<a href="http://docs.jquery.com/Plugins" target="_blank">jQuery 插件</a>：获取可以使用的 jQuery 插件的完整列表。<br />
	<a href="http://interface.eyecon.ro/" target="_blank">Interface</a>：尝试使用 jQuery 最基本的插件，可用于动画、显示效果、拖放功能和用户界面（UI）。<br />
	<a href="http://jquery.com/dev/svn/trunk/plugins/form/form.js?format=txt" target="_blank">Form 插件</a>：获取 jQuery 插件，它可用于使用 Ajax 提交表单。</p>
<p><strong>讨论</strong></p>
<p>	<a href="http://jquery.com/blog/" target="_blank">jQuery 博客</a>：有关 jQuery 的日常新闻和更新，请经常访问官方的 jQuery blog。<br />
	<a href="http://www.ibm.com/developerworks/forums/dw_xforums.jsp" target="_blank">XML 专区讨论论坛</a>：参与任何以 XML 为中心的论坛。</p>
<p>注：文中的“我”不是bolo，是这问仁兄：<a href="http://www.ibm.com/developerworks/cn/xml/x-ajaxjquery.html" target="_blank">http://www.ibm.com/developerworks/cn/xml/x-ajaxjquery.html</a>。</ul>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/" title="利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件">利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</a></li><li><a href="http://blog.imbolo.com/jquery-jwtabs/" title="jQuery插件：jwTabs">jQuery插件：jwTabs</a></li><li><a href="http://blog.imbolo.com/make-a-jquery-style-switch/" title="用jQuery制作页面风格切换开关">用jQuery制作页面风格切换开关</a></li><li><a href="http://blog.imbolo.com/make-a-door-effect-in-jquery-and-css/" title="jQuery+CSS制作滑动门效果">jQuery+CSS制作滑动门效果</a></li><li><a href="http://blog.imbolo.com/jquery-make-the-link-background-fadein-effect/" title="jQuery实现链接背景淡出淡入效果">jQuery实现链接背景淡出淡入效果</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/make-ajax-with-jquery/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>jQuery+CSS制作滑动门效果</title>
		<link>http://blog.imbolo.com/make-a-door-effect-in-jquery-and-css/</link>
		<comments>http://blog.imbolo.com/make-a-door-effect-in-jquery-and-css/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 23:21:10 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WEB]]></category>

		<guid isPermaLink="false">http://digau.cn/?p=946</guid>
		<description><![CDATA[本例利用jQuery实现背景图像动画效果。我们可以利用这种特效做一个“滑动门“菜单。]]></description>
			<content:encoded><![CDATA[<p>本例利用jQuery实现背景图像动画效果。我们可以利用这种特效做一个“滑动门”菜单。请看<a href="http://test.digau.cn/garagedoormenu" target="_blank">demo</a>。</p>
<p>这个效果的实现方法：<br />
创建一个jquery.backgroundPosition.js文件，内容如下：<br />
<span id="more-946"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$.<span style="color: #006633;">extend</span><span style="color: #009900;">&#40;</span>$.<span style="color: #006633;">fx</span>.<span style="color: #006633;">step</span>,<span style="color: #009900;">&#123;</span>
	    backgroundPosition<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span>fx<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fx.<span style="color: #006633;">state</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">&amp;&amp;</span> typeof fx.<span style="color: #006633;">end</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'string'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                var start <span style="color: #339933;">=</span> $.<span style="color: #006633;">curCSS</span><span style="color: #009900;">&#40;</span>fx.<span style="color: #006633;">elem</span>,<span style="color: #0000ff;">'backgroundPosition'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                start <span style="color: #339933;">=</span> toArray<span style="color: #009900;">&#40;</span>start<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                fx.<span style="color: #006633;">start</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>start<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>,start<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                var end <span style="color: #339933;">=</span> toArray<span style="color: #009900;">&#40;</span>fx.<span style="color: #006633;">end</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                fx.<span style="color: #006633;">end</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>end<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>,end<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                fx.<span style="color: #006633;">unit</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>end<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>,end<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
            var nowPosX <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            nowPosX<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>fx.<span style="color: #006633;">end</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> fx.<span style="color: #006633;">start</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> fx.<span style="color: #006633;">pos</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> fx.<span style="color: #006633;">start</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> fx.<span style="color: #006633;">unit</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            nowPosX<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>fx.<span style="color: #006633;">end</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> fx.<span style="color: #006633;">start</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> fx.<span style="color: #006633;">pos</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> fx.<span style="color: #006633;">start</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> fx.<span style="color: #006633;">unit</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>           
            fx.<span style="color: #006633;">elem</span>.<span style="color: #006633;">style</span>.<span style="color: #006633;">backgroundPosition</span> <span style="color: #339933;">=</span> nowPosX<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">' '</span><span style="color: #339933;">+</span>nowPosX<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
           function toArray<span style="color: #009900;">&#40;</span>strg<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
               strg <span style="color: #339933;">=</span> strg.<span style="color: #006633;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span>left<span style="color: #339933;">|</span>top<span style="color: #339933;">/</span>g,<span style="color: #0000ff;">'0px'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               strg <span style="color: #339933;">=</span> strg.<span style="color: #006633;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span>right<span style="color: #339933;">|</span>bottom<span style="color: #339933;">/</span>g,<span style="color: #0000ff;">'100%'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               strg <span style="color: #339933;">=</span> strg.<span style="color: #006633;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span>\.<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>\s<span style="color: #339933;">|</span>\<span style="color: #009900;">&#41;</span><span style="color: #339933;">|</span>$<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span>g,<span style="color: #0000ff;">&quot;$1px$2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               var res <span style="color: #339933;">=</span> strg.<span style="color: #006633;">match</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-?</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span>\.<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>px<span style="color: #339933;">|</span>\<span style="color: #339933;">%|</span>em<span style="color: #339933;">|</span>pt<span style="color: #009900;">&#41;</span>\s<span style="color: #009900;">&#40;</span><span style="color: #339933;">-?</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span>\.<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>px<span style="color: #339933;">|</span>\<span style="color: #339933;">%|</span>em<span style="color: #339933;">|</span>pt<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span>parseFloat<span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>,<span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>,res<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span>,parseFloat<span style="color: #009900;">&#40;</span>res<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span>,<span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>,res<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
           <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>建立html文件，内容如下：</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt; !DOCTYPE html PUBLIC <span style="color: #ff0000;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span style="color: #ff0000;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span> xmlns<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">meta</span> <span style="color: #000066;">http-equiv</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/html; charset=UTF-8&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>Garage Door Menu from CSS-Tricks<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">style</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span>&gt;</span>
	<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">	* { margin:0px; padding:0px; }</span>
<span style="color: #808080; font-style: italic;">	body { background:#c1c1c1; }</span>
<span style="color: #808080; font-style: italic;">	a  { outline-style: none; }</span>
&nbsp;
<span style="color: #808080; font-style: italic;">	ul#menuback {</span>
<span style="color: #808080; font-style: italic;">	margin: 50px auto;</span>
<span style="color: #808080; font-style: italic;">	list-style: none;</span>
<span style="color: #808080; font-style: italic;">	background: url(../images/menu-bg.jpg);</span>
<span style="color: #808080; font-style: italic;">	width: 800px;</span>
<span style="color: #808080; font-style: italic;">	overflow: auto;	</span>
<span style="color: #808080; font-style: italic;">	}</span>
&nbsp;
<span style="color: #808080; font-style: italic;">	ul#menuback li.shutter {</span>
<span style="color: #808080; font-style: italic;">	width: 200px;</span>
<span style="color: #808080; font-style: italic;">	height: 100px;</span>
<span style="color: #808080; font-style: italic;">	display: block;</span>
<span style="color: #808080; font-style: italic;">	float: left;</span>
<span style="color: #808080; font-style: italic;">	}</span>
&nbsp;
<span style="color: #808080; font-style: italic;">	ul#menuback li#shutter1 {</span>
<span style="color: #808080; font-style: italic;">	background: url(../images/shutter-africanplains.jpg) no-repeat; </span>
<span style="color: #808080; font-style: italic;">	}</span>
<span style="color: #808080; font-style: italic;">	ul#menuback li#shutter2 {</span>
<span style="color: #808080; font-style: italic;">	background: url(../images/shutter-reptiles.jpg) no-repeat; </span>
<span style="color: #808080; font-style: italic;">	}</span>
<span style="color: #808080; font-style: italic;">	ul#menuback li#shutter3 {</span>
<span style="color: #808080; font-style: italic;">	background: url(../images/shutter-aviary.jpg) no-repeat; </span>
<span style="color: #808080; font-style: italic;">	}</span>
<span style="color: #808080; font-style: italic;">	ul#menuback li#shutter4 {</span>
<span style="color: #808080; font-style: italic;">	background: url(../images/shutter-arcticzone.jpg) no-repeat; </span>
<span style="color: #808080; font-style: italic;">	}</span>
&nbsp;
<span style="color: #808080; font-style: italic;">	a.link {</span>
<span style="color: #808080; font-style: italic;">	width: 200px;</span>
<span style="color: #808080; font-style: italic;">	height: 100px;</span>
<span style="color: #808080; font-style: italic;">	display: block;</span>
<span style="color: #808080; font-style: italic;">	background: url(../images/window.png) no-repeat bottom center;</span>
<span style="color: #808080; font-style: italic;">	text-indent: -9999px;</span>
<span style="color: #808080; font-style: italic;">	}</span>
<span style="color: #808080; font-style: italic;">	--&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;jquery.backgroundPosition.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
		$(document).ready(function() {
&nbsp;
			//Set css in Firefox (Required to use the backgroundPosition js)
			$('#shutter1').css({backgroundPosition: '0px 0px'});
			$('#shutter2').css({backgroundPosition: '0px 0px'});
			$('#shutter3').css({backgroundPosition: '0px 0px'});
			$('#shutter4').css({backgroundPosition: '0px 0px'});
&nbsp;
			//Animate the shutter  
			$(&quot;.link&quot;).hover(function(){
			      $(this).parent().animate({backgroundPosition: '(0px -100px)'}, 500 );
			    }, function() {
			      $(this).parent().animate({backgroundPosition: '(0px 0px)'}, 500 );
			}); 
		 });
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menuback&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shutter&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shutter1&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;link&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#1&quot;</span>&gt;</span>Link 1<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shutter&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shutter2&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;link&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#2&quot;</span>&gt;</span>Link 2<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shutter&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shutter3&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;link&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#3&quot;</span>&gt;</span>Link 3<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shutter&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shutter4&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;link&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#4&quot;</span>&gt;</span>Link 4<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>可见这个效果的html结构是非常简单的，重点是好好地利用jQuery提供的效果。</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/" title="利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件">利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</a></li><li><a href="http://blog.imbolo.com/jquery-jwtabs/" title="jQuery插件：jwTabs">jQuery插件：jwTabs</a></li><li><a href="http://blog.imbolo.com/make-a-jquery-style-switch/" title="用jQuery制作页面风格切换开关">用jQuery制作页面风格切换开关</a></li><li><a href="http://blog.imbolo.com/make-ajax-with-jquery/" title="使用 jQuery 简化 Ajax 开发">使用 jQuery 简化 Ajax 开发</a></li><li><a href="http://blog.imbolo.com/jquery-make-the-link-background-fadein-effect/" title="jQuery实现链接背景淡出淡入效果">jQuery实现链接背景淡出淡入效果</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/make-a-door-effect-in-jquery-and-css/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>jQuery实现链接背景淡出淡入效果</title>
		<link>http://blog.imbolo.com/jquery-make-the-link-background-fadein-effect/</link>
		<comments>http://blog.imbolo.com/jquery-make-the-link-background-fadein-effect/#comments</comments>
		<pubDate>Mon, 08 Jun 2009 06:11:58 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WEB]]></category>

		<guid isPermaLink="false">http://digau.cn/?p=941</guid>
		<description><![CDATA[仅通过css的hover属性实现简单的背景变换已经满足不了一些追求美观的人。本实例即教大家如何在不修改原有CSS代码的前提下，使用jQuery实现光标悬停在链接上时的淡入淡出效果。]]></description>
			<content:encoded><![CDATA[<p>仅通过css的hover属性实现简单的背景变换已经满足不了一些追求美观的人。本实例即教大家如何在不修改原有CSS代码的前提下，使用jQuery实现光标悬停在链接上时的淡入淡出效果。</p>
<p>请看演示：<a href="http://test.digau.cn/fadeover/" target="_blank">demo</a>。</p>
<p>通过演示，你可以发现例子里面，当鼠标停在链接上方是，背景图片会有一个淡出淡入过渡效果。实现这种效果的原理是这样的：</p>
<p>在此函数代码（linkFader.jquery.js）的帮助下，我们只需在链接标签&#60;&#97;&#62;上添加一个名为“linkFader”的Class类，就可实现鼠标悬停在链接上时的淡入淡出效果。即使客户端的JavaScript处于不可用状态，CSS文件里面的HOVER效果仍将起作用。<br />
请注意，要想使这个淡入淡出效果起作用，我们的链接标签&#60;&#97;&#62;必须使用图片替换技术（即&#60;&#97;&#62;需在CSS中定义为图片链接，具体请参考示例中的写法）来编写CSS代码，否则代码将不会起作用。这是因为此函数代码是基于背景（图片）位置偏移原理所编写，如果没有图片作为链接&#60;&#97;&#62;的背景，偏移也就无从谈起了。</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/" title="利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件">利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</a></li><li><a href="http://blog.imbolo.com/jquery-jwtabs/" title="jQuery插件：jwTabs">jQuery插件：jwTabs</a></li><li><a href="http://blog.imbolo.com/make-a-jquery-style-switch/" title="用jQuery制作页面风格切换开关">用jQuery制作页面风格切换开关</a></li><li><a href="http://blog.imbolo.com/make-ajax-with-jquery/" title="使用 jQuery 简化 Ajax 开发">使用 jQuery 简化 Ajax 开发</a></li><li><a href="http://blog.imbolo.com/make-a-door-effect-in-jquery-and-css/" title="jQuery+CSS制作滑动门效果">jQuery+CSS制作滑动门效果</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/jquery-make-the-link-background-fadein-effect/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>jQuery+CSS制作下拉菜单</title>
		<link>http://blog.imbolo.com/make-dropdown-menu-with-jquery-css/</link>
		<comments>http://blog.imbolo.com/make-dropdown-menu-with-jquery-css/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 12:10:38 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WEB]]></category>

		<guid isPermaLink="false">http://digau.cn/?p=938</guid>
		<description><![CDATA[从有图形操作系统开始，下拉菜单和菜单栏就占据一个重要地位。到现在，它们的使用已经无处不在。甚至桌面应用程序和网页设计也在跟随这种设计。本文旨在简单睇讲解如何在你的网页中利用jQuery和CSS技术加入强大的下拉菜单。
]]></description>
			<content:encoded><![CDATA[<p>看这篇文章之前请先看看效果：<a href="http://test.digau.cn/jQuery%20_%20CSS%20Example%20-%20Dropdown%20Menu.htm" target="_blank">demo</a>。<br />
从有图形操作系统开始，下拉菜单和菜单栏就占据一个重要地位。到现在，它们的使用已经无处不在。甚至桌面应用程序和网页设计也在跟随这种潮流。本文旨在简单睇讲解如何在你的网页中利用jQuery和CSS技术加入强大的下拉菜单。</p>
<p><strong>入门</strong><br />
首先，我们需要确定基本菜单级数，为了保持语法结构，我们将使用无序列表（ul）链接标准。我们将使用下面的代码作为一个例子。<br />
<span id="more-938"></span></p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cssdropdown&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;headlink&quot;</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://digan.cn&quot;</span>&gt;</span>Search Engines<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
	 <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://digan.cn&quot;</span>&gt;</span>Google<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://digan.cn/&quot;</span>&gt;</span>Yahoo<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://digan.cn/&quot;</span>&gt;</span>Live Search<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	 <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	 <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;headlink&quot;</span>&gt;</span>
	  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://digan.cn&quot;</span>&gt;</span>Shopping<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
         <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
	  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://digan.cn/&quot;</span>&gt;</span>Amazon<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://digan.cn/&quot;</span>&gt;</span>eBay<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://digan.cn/&quot;</span>&gt;</span>CraigsList<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
	 <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
 <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>

<p>效果如下：<br />
<a href="http://lh6.ggpht.com/_mqHDn57CquM/SiumavpQwpI/AAAAAAAAAq0/Vz59s3Hmeo0/jQuery%2BCSS%E5%88%9B%E5%BB%BA%E4%B8%8B%E6%8B%89%E8%8F%9C%E5%8D%951.jpg?imgmax=800" class="highslide" onclick="return hs.expand(this)" rel="2009-5-0-19-37-46"><img src="http://lh6.ggpht.com/_mqHDn57CquM/SiumavpQwpI/AAAAAAAAAq0/Vz59s3Hmeo0/jQuery%2BCSS%E5%88%9B%E5%BB%BA%E4%B8%8B%E6%8B%89%E8%8F%9C%E5%8D%951.jpg?imgmax=400" alt="jQuery+CSS创建下拉菜单1.jpg" class="pie-img" style="margin:10px 10px 10px 10px;"/></a></p>
<p><strong>创建下拉列表</strong><br />
把HTML语句和链接结构写好以后，我们可以在css中添加一些基本属性，提示：hover属性表示鼠标悬停在相应项目上是的样式。<br />
我们可以通过css来清楚无序列表（ul）的默认样式。并设置列表项目在鼠标滑过是的样式。例如：</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">       li<span style="color: #6666ff;">.headlink</span> ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
       li<span style="color: #6666ff;">.headlink</span><span style="color: #3333ff;">:hover </span>ul <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>最好在这个时候为菜单列表设置一些基本的样式，例如：对齐属性和宽度等，以确保菜单在显示和隐藏的时候不会变形。<br />
完成这一步以后，我的效果如下：<br />
<a href="http://lh4.ggpht.com/_mqHDn57CquM/SiumayPhrBI/AAAAAAAAAq4/EYDmrQZc9_4/jQuery%2BCSS%E5%88%9B%E5%BB%BA%E4%B8%8B%E6%8B%89%E8%8F%9C%E5%8D%952.jpg?imgmax=800" class="highslide" onclick="return hs.expand(this)" rel="2009-5-0-19-50-7"><img src="http://lh4.ggpht.com/_mqHDn57CquM/SiumayPhrBI/AAAAAAAAAq4/EYDmrQZc9_4/jQuery%2BCSS%E5%88%9B%E5%BB%BA%E4%B8%8B%E6%8B%89%E8%8F%9C%E5%8D%952.jpg?imgmax=400" alt="jQuery+CSS创建下拉菜单2.jpg" class="pie-img" style="margin:10px 10px 10px 10px;"/></a></p>
<p><strong>解决兼容性问题</strong><br />
很遗憾，IE对hover属性支持得并不太好，在这一点上，一段精短的JavaScript就可以解决这个问题。我们需要做的是为ul标签里所有class=headlink的项目加上onmouseover和onmouseout事件，这个问题可以用一下js脚本解决：</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">	window.<span style="color: #006633;">onload</span> <span style="color: #339933;">=</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		var lis <span style="color: #339933;">=</span> document.<span style="color: #006633;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'li'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> lis.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			var li <span style="color: #339933;">=</span> lis<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>li.<span style="color: #006633;">className</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'headlink'</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				li.<span style="color: #006633;">onmouseover</span> <span style="color: #339933;">=</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">style</span>.<span style="color: #006633;">display</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'block'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
				li.<span style="color: #006633;">onmouseout</span> <span style="color: #339933;">=</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">item</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">style</span>.<span style="color: #006633;">display</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'none'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>使用jQuery库的朋友则有一个更加简单的办法，使用下面的语句：
</pre>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">	$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">ready</span><span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'li.headlink'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">hover</span><span style="color: #009900;">&#40;</span>
			function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ul'</span>, <span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'display'</span>, <span style="color: #0000ff;">'block'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>,
			function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ul'</span>, <span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'display'</span>, <span style="color: #0000ff;">'none'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>完成这一步后，你可以看到如下效果：<br />
<a href="http://lh6.ggpht.com/_mqHDn57CquM/SiumaTFRjUI/AAAAAAAAAqw/r4lYQ32Y6m8/jQuery%2BCSS%E5%88%9B%E5%BB%BA%E4%B8%8B%E6%8B%89%E8%8F%9C%E5%8D%953.jpg?imgmax=800" class="highslide" onclick="return hs.expand(this)" rel="2009-5-0-20-7-21"><img src="http://lh6.ggpht.com/_mqHDn57CquM/SiumaTFRjUI/AAAAAAAAAqw/r4lYQ32Y6m8/jQuery%2BCSS%E5%88%9B%E5%BB%BA%E4%B8%8B%E6%8B%89%E8%8F%9C%E5%8D%953.jpg?imgmax=400" alt="jQuery+CSS创建下拉菜单3.jpg" class="pie-img" style="margin:10px 10px 10px 10px;"/></a></p>
<p><strong>整理代码</strong><br />
现在，这个下拉菜单已经可以在大多数主流浏览器上正常运行，接下来要做的就是美化，整理代码，上线。<br />
使用无需列表比标准列表更有利于设置基本样式，就是因为这一点，我们能更容易地设计出自己喜欢的菜单样式。</p>
<p><strong>后期润色</strong><br />
设置一些符合网站风格的样式，并添加一些更加帅的特效。</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/" title="利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件">利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</a></li><li><a href="http://blog.imbolo.com/jquery-jwtabs/" title="jQuery插件：jwTabs">jQuery插件：jwTabs</a></li><li><a href="http://blog.imbolo.com/make-a-jquery-style-switch/" title="用jQuery制作页面风格切换开关">用jQuery制作页面风格切换开关</a></li><li><a href="http://blog.imbolo.com/make-ajax-with-jquery/" title="使用 jQuery 简化 Ajax 开发">使用 jQuery 简化 Ajax 开发</a></li><li><a href="http://blog.imbolo.com/make-a-door-effect-in-jquery-and-css/" title="jQuery+CSS制作滑动门效果">jQuery+CSS制作滑动门效果</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/make-dropdown-menu-with-jquery-css/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>用jquery制作平滑弹出菜单</title>
		<link>http://blog.imbolo.com/make-a-dropdown-menu-in-jquery/</link>
		<comments>http://blog.imbolo.com/make-a-dropdown-menu-in-jquery/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 04:30:34 +0000</pubDate>
		<dc:creator>bolo</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WEB]]></category>

		<guid isPermaLink="false">http://digau.cn/?p=925</guid>
		<description><![CDATA[用jquery制作平滑弹出菜单]]></description>
			<content:encoded><![CDATA[<p>先看看演示<a href="http://test.digau.cn/Smooth%20Navigational%20Menu.html" target=_blank>demo</a>，效果华丽吧？<br />
<a href="http://lh4.ggpht.com/_mqHDn57CquM/Sinxw26jF3I/AAAAAAAAAo8/kFegw6tn0Lw/Smooth-Navigational-Menu.gif.jpg?imgmax=800" class="highslide" onclick="return hs.expand(this)" rel="2009-5-6-12-34-31"><img src="http://lh4.ggpht.com/_mqHDn57CquM/Sinxw26jF3I/AAAAAAAAAo8/kFegw6tn0Lw/Smooth-Navigational-Menu.gif.jpg?imgmax=400" alt="Smooth-Navigational-Menu.gif.jpg" class="pie-img" style="margin:10px 10px 10px 10px;"/></a><br />
以下是源代码<br />
<span id="more-925"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> <span style="color: #339933;">!</span>DOCTYPE html <span style="color: #000000; font-weight: bold;">PUBLIC</span> <span style="color: #0000ff;">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span style="color: #0000ff;">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>html xmlns<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.w3.org/1999/xhtml&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>style type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/css&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #666666; font-style: italic;">/*Example 1 Style*/</span>
.<span style="color: #006633;">ddsmoothmenu</span><span style="color: #009900;">&#123;</span>
font<span style="color: #339933;">:</span> bold 12px Verdana<span style="color: #339933;">;</span>
background<span style="color: #339933;">:</span> #<span style="color: #cc66cc;">414141</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/*background of menu bar (default state)*/</span>
width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">%;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
.<span style="color: #006633;">ddsmoothmenu</span> ul<span style="color: #009900;">&#123;</span>
z<span style="color: #339933;">-</span>index<span style="color: #339933;">:</span><span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span>
margin<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
padding<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
list<span style="color: #339933;">-</span>style<span style="color: #339933;">-</span>type<span style="color: #339933;">:</span> none<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*Top level list items*/</span>
.<span style="color: #006633;">ddsmoothmenu</span> ul li<span style="color: #009900;">&#123;</span>
position<span style="color: #339933;">:</span> relative<span style="color: #339933;">;</span>
display<span style="color: #339933;">:</span> inline<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">float</span><span style="color: #339933;">:</span> left<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*Top level menu link items style*/</span>
.<span style="color: #006633;">ddsmoothmenu</span> ul li a<span style="color: #009900;">&#123;</span>
display<span style="color: #339933;">:</span> block<span style="color: #339933;">;</span>
background<span style="color: #339933;">:</span> #<span style="color: #cc66cc;">414141</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/*background of menu items (default state)*/</span>
color<span style="color: #339933;">:</span> white<span style="color: #339933;">;</span>
padding<span style="color: #339933;">:</span> 8px 10px<span style="color: #339933;">;</span>
border<span style="color: #339933;">-</span>right<span style="color: #339933;">:</span> 1px solid #<span style="color: #cc66cc;">778</span><span style="color: #339933;">;</span>
color<span style="color: #339933;">:</span> #2d2b2b<span style="color: #339933;">;</span>
text<span style="color: #339933;">-</span>decoration<span style="color: #339933;">:</span> none<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #339933;">*</span> html .<span style="color: #006633;">ddsmoothmenu</span> ul li a<span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">/*IE6 hack to get sub menu links to behave correctly*/</span>
display<span style="color: #339933;">:</span> inline<span style="color: #339933;">-</span>block<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
.<span style="color: #006633;">ddsmoothmenu</span> ul li a<span style="color: #339933;">:</span>link, .<span style="color: #006633;">ddsmoothmenu</span> ul li a<span style="color: #339933;">:</span>visited<span style="color: #009900;">&#123;</span>
color<span style="color: #339933;">:</span> white<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
.<span style="color: #006633;">ddsmoothmenu</span> ul li a.<span style="color: #006633;">selected</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">/*CSS class that's dynamically added to the currently active menu items' LI A element*/</span>
background<span style="color: #339933;">:</span> black<span style="color: #339933;">;</span> 
color<span style="color: #339933;">:</span> white<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
.<span style="color: #006633;">ddsmoothmenu</span> ul li a<span style="color: #339933;">:</span>hover<span style="color: #009900;">&#123;</span>
background<span style="color: #339933;">:</span> black<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/*background of menu items during onmouseover (hover state)*/</span>
color<span style="color: #339933;">:</span> white<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*1st sub level menu*/</span>
.<span style="color: #006633;">ddsmoothmenu</span> ul li ul<span style="color: #009900;">&#123;</span>
position<span style="color: #339933;">:</span> absolute<span style="color: #339933;">;</span>
left<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
display<span style="color: #339933;">:</span> none<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/*collapse all sub menus to begin with*/</span>
visibility<span style="color: #339933;">:</span> hidden<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*Sub level menu list items (undo style from Top level List Items)*/</span>
.<span style="color: #006633;">ddsmoothmenu</span> ul li ul li<span style="color: #009900;">&#123;</span>
display<span style="color: #339933;">:</span> list<span style="color: #339933;">-</span>item<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">float</span><span style="color: #339933;">:</span> none<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*All subsequent sub menu levels vertical offset after 1st level sub menu */</span>
.<span style="color: #006633;">ddsmoothmenu</span> ul li ul li ul<span style="color: #009900;">&#123;</span>
top<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Sub level menu links style */</span>
.<span style="color: #006633;">ddsmoothmenu</span> ul li ul li a<span style="color: #009900;">&#123;</span>
font<span style="color: #339933;">:</span> normal 13px Verdana<span style="color: #339933;">;</span>
width<span style="color: #339933;">:</span> 160px<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/*width of sub menus*/</span>
padding<span style="color: #339933;">:</span> 5px<span style="color: #339933;">;</span>
margin<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
border<span style="color: #339933;">-</span>top<span style="color: #339933;">-</span>width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
border<span style="color: #339933;">-</span>bottom<span style="color: #339933;">:</span> 1px solid gray<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Holly Hack for IE \*/</span>
<span style="color: #339933;">*</span> html .<span style="color: #006633;">ddsmoothmenu</span><span style="color: #009900;">&#123;</span>height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">%;</span><span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">/*Holly Hack for IE7 and below*/</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">/* ######### CSS classes applied to down and right arrow images  ######### */</span>
&nbsp;
.<span style="color: #006633;">downarrowclass</span><span style="color: #009900;">&#123;</span>
position<span style="color: #339933;">:</span> absolute<span style="color: #339933;">;</span>
top<span style="color: #339933;">:</span> 12px<span style="color: #339933;">;</span>
right<span style="color: #339933;">:</span> 7px<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
.<span style="color: #006633;">rightarrowclass</span><span style="color: #009900;">&#123;</span>
position<span style="color: #339933;">:</span> absolute<span style="color: #339933;">;</span>
top<span style="color: #339933;">:</span> 6px<span style="color: #339933;">;</span>
right<span style="color: #339933;">:</span> 5px<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* ######### CSS for shadow added to sub menus  ######### */</span>
&nbsp;
.<span style="color: #006633;">ddshadow</span><span style="color: #009900;">&#123;</span>
position<span style="color: #339933;">:</span> absolute<span style="color: #339933;">;</span>
left<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
top<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
background<span style="color: #339933;">:</span> silver<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
.<span style="color: #006633;">toplevelshadow</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">/*shadow opacity. Doesn't work in IE*/</span>
opacity<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0.8</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*Example 2 Style*/</span>
.<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul<span style="color: #009900;">&#123;</span>
margin<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
padding<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
width<span style="color: #339933;">:</span> 170px<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* Main Menu Item widths */</span>
list<span style="color: #339933;">-</span>style<span style="color: #339933;">-</span>type<span style="color: #339933;">:</span> none<span style="color: #339933;">;</span>
font<span style="color: #339933;">:</span> bold 12px Verdana<span style="color: #339933;">;</span>
&nbsp;
border<span style="color: #339933;">-</span>bottom<span style="color: #339933;">:</span> 1px solid #ccc<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
.<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul li<span style="color: #009900;">&#123;</span>
position<span style="color: #339933;">:</span> relative<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Top level menu links style */</span>
.<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul li a<span style="color: #009900;">&#123;</span>
display<span style="color: #339933;">:</span> block<span style="color: #339933;">;</span>
overflow<span style="color: #339933;">:</span> auto<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/*force hasLayout in IE7 */</span>
color<span style="color: #339933;">:</span> white<span style="color: #339933;">;</span>
text<span style="color: #339933;">-</span>decoration<span style="color: #339933;">:</span> none<span style="color: #339933;">;</span>
padding<span style="color: #339933;">:</span> 6px<span style="color: #339933;">;</span>
border<span style="color: #339933;">-</span>bottom<span style="color: #339933;">:</span> 1px solid #<span style="color: #cc66cc;">778</span><span style="color: #339933;">;</span>
border<span style="color: #339933;">-</span>right<span style="color: #339933;">:</span> 1px solid #<span style="color: #cc66cc;">778</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
.<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul li a<span style="color: #339933;">:</span>link, .<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul li a<span style="color: #339933;">:</span>visited, .<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul li a<span style="color: #339933;">:</span>active<span style="color: #009900;">&#123;</span>
background<span style="color: #339933;">:</span> #<span style="color: #cc66cc;">414141</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/*background of menu items (default state)*/</span>
color<span style="color: #339933;">:</span> white<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
.<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul li a.<span style="color: #006633;">selected</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">/*CSS class that's dynamically added to the currently active menu items' LI A element*/</span>
background<span style="color: #339933;">:</span> black<span style="color: #339933;">;</span> 
color<span style="color: #339933;">:</span> white<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
.<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul li a<span style="color: #339933;">:</span>hover<span style="color: #009900;">&#123;</span>
background<span style="color: #339933;">:</span> black<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/*background of menu items during onmouseover (hover state)*/</span>
color<span style="color: #339933;">:</span> white<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*Sub level menu items */</span>
.<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul li ul<span style="color: #009900;">&#123;</span>
position<span style="color: #339933;">:</span> absolute<span style="color: #339933;">;</span>
width<span style="color: #339933;">:</span> 170px<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/*Sub Menu Items width */</span>
top<span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
font<span style="color: #339933;">-</span>weight<span style="color: #339933;">:</span> normal<span style="color: #339933;">;</span>
visibility<span style="color: #339933;">:</span> hidden<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">/* Holly Hack for IE \*/</span>
<span style="color: #339933;">*</span> html .<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul li <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">float</span><span style="color: #339933;">:</span> left<span style="color: #339933;">;</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">%;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">*</span> html .<span style="color: #006633;">ddsmoothmenu</span><span style="color: #339933;">-</span>v ul li a <span style="color: #009900;">&#123;</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">%;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #666666; font-style: italic;">/* End */</span>
<span style="color: #339933;">&lt;/</span>style<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>meta http<span style="color: #339933;">-</span>equiv<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Content-Type&quot;</span> content<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/html; charset=utf-8&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>Smooth Navigational <span style="color: #003399;">Menu</span> <span style="color: #339933;">&lt;/</span>title<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;ddsmoothmenu.js&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/***********************************************
* Smooth Navigational Menu
* This notice MUST stay intact for legal use
* Collection by bolo(http://digau.cn)
***********************************************/</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//** 1) Now supports vertical (side bar) menu mode- set &quot;orientation&quot; to 'v'</span>
<span style="color: #666666; font-style: italic;">//** 2) In IE6, shadows are now always disabled</span>
&nbsp;
&nbsp;
var ddsmoothmenu<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Specify full URL to down and right arrow images (23 is padding-right added to top level LIs with drop downs):</span>
<span style="color: #666666; font-style: italic;">//arrowimages: {down:['downarrowclass', 'down.gif', 23], right:['rightarrowclass', 'right.gif']},you can edit this row</span>
&nbsp;
transition<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>overtime<span style="color: #339933;">:</span><span style="color: #cc66cc;">300</span>, outtime<span style="color: #339933;">:</span><span style="color: #cc66cc;">300</span><span style="color: #009900;">&#125;</span>, <span style="color: #666666; font-style: italic;">//duration of slide in/ out animation, in milliseconds</span>
shadow<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>enabled<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">true</span>, offsetx<span style="color: #339933;">:</span><span style="color: #cc66cc;">5</span>, offsety<span style="color: #339933;">:</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#125;</span>,
&nbsp;
<span style="color: #666666; font-style: italic;">///////Stop configuring beyond here///////////////////////////</span>
&nbsp;
detectwebkit<span style="color: #339933;">:</span> navigator.<span style="color: #006633;">userAgent</span>.<span style="color: #006633;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;applewebkit&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=-</span><span style="color: #cc66cc;">1</span>, <span style="color: #666666; font-style: italic;">//detect WebKit browsers (Safari, Chrome etc)</span>
detectie6<span style="color: #339933;">:</span> document.<span style="color: #006633;">all</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>window.<span style="color: #006633;">XMLHttpRequest</span>,
&nbsp;
getajaxmenu<span style="color: #339933;">:</span>function<span style="color: #009900;">&#40;</span>$, setting<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//function to fetch external page containing the panel DIVs</span>
	var $menucontainer<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'#'</span><span style="color: #339933;">+</span>setting.<span style="color: #006633;">contentsource</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//reference empty div on page that will hold menu</span>
	$menucontainer.<span style="color: #006633;">html</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Loading Menu...&quot;</span><span style="color: #009900;">&#41;</span>
	$.<span style="color: #006633;">ajax</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		url<span style="color: #339933;">:</span> setting.<span style="color: #006633;">contentsource</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>, <span style="color: #666666; font-style: italic;">//path to external menu file</span>
		async<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>,
		error<span style="color: #339933;">:</span>function<span style="color: #009900;">&#40;</span>ajaxrequest<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$menucontainer.<span style="color: #006633;">html</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error fetching content. Server Response: '</span><span style="color: #339933;">+</span>ajaxrequest.<span style="color: #006633;">responseText</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#125;</span>,
		success<span style="color: #339933;">:</span>function<span style="color: #009900;">&#40;</span>content<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$menucontainer.<span style="color: #006633;">html</span><span style="color: #009900;">&#40;</span>content<span style="color: #009900;">&#41;</span>
			ddsmoothmenu.<span style="color: #006633;">buildmenu</span><span style="color: #009900;">&#40;</span>$, setting<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>,
&nbsp;
&nbsp;
buildmenu<span style="color: #339933;">:</span>function<span style="color: #009900;">&#40;</span>$, setting<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	var smoothmenu<span style="color: #339933;">=</span>ddsmoothmenu
	var $mainmenu<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">+</span>setting.<span style="color: #006633;">mainmenuid</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;&gt;ul&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//reference main menu UL</span>
	$mainmenu.<span style="color: #006633;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">className</span><span style="color: #339933;">=</span>setting.<span style="color: #006633;">classname</span> <span style="color: #339933;">||</span> <span style="color: #0000ff;">&quot;ddsmoothmenu&quot;</span>
	var $headers<span style="color: #339933;">=</span>$mainmenu.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	$headers.<span style="color: #006633;">hover</span><span style="color: #009900;">&#40;</span>
		function<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">children</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a:eq(0)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'selected'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#125;</span>,
		function<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">children</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'a:eq(0)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'selected'</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#41;</span>
	$headers.<span style="color: #006633;">each</span><span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//loop through each LI header</span>
		var $curobj<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>zIndex<span style="color: #339933;">:</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">-</span>i<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//reference current LI header</span>
		var $subul<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ul:eq(0)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>display<span style="color: #339933;">:</span><span style="color: #0000ff;">'block'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000000; font-weight: bold;">this</span>._dimensions<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>w<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">offsetWidth</span>, h<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">offsetHeight</span>, subulw<span style="color: #339933;">:</span>$subul.<span style="color: #006633;">outerWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, subulh<span style="color: #339933;">:</span>$subul.<span style="color: #006633;">outerHeight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span><span style="color: #339933;">=</span>$curobj.<span style="color: #006633;">parents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">length</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">?</span> <span style="color: #000066; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">false</span> <span style="color: #666666; font-style: italic;">//is top level header?</span>
		$subul.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>top<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span> <span style="color: #339933;">&amp;&amp;</span> setting.<span style="color: #006633;">orientation</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">'v'</span><span style="color: #339933;">?</span> <span style="color: #000000; font-weight: bold;">this</span>._dimensions.<span style="color: #006633;">h</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;px&quot;</span> <span style="color: #339933;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #666666; font-style: italic;">//$curobj.children(&quot;a:eq(0)&quot;).css(this.istopheader? {paddingRight: smoothmenu.arrowimages.down[2]} : {}).append( //add arrow images</span>
			<span style="color: #666666; font-style: italic;">//'&lt;img src=&quot;'+ (this.istopheader &amp;&amp; setting.orientation!='v'? smoothmenu.arrowimages.down[1] : smoothmenu.arrowimages.right[1])</span>
			<span style="color: #666666; font-style: italic;">//+'&quot; class=&quot;' + (this.istopheader &amp;&amp; setting.orientation!='v'? smoothmenu.arrowimages.down[0] : smoothmenu.arrowimages.right[0])</span>
			<span style="color: #666666; font-style: italic;">//+ '&quot; style=&quot;border:0;&quot; /&gt;'</span>
		<span style="color: #666666; font-style: italic;">//)</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>smoothmenu.<span style="color: #006633;">shadow</span>.<span style="color: #006633;">enabled</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">this</span>._shadowoffset<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>x<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span><span style="color: #339933;">?</span>$subul.<span style="color: #006633;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">left</span><span style="color: #339933;">+</span>smoothmenu.<span style="color: #006633;">shadow</span>.<span style="color: #006633;">offsetx</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">this</span>._dimensions.<span style="color: #006633;">w</span><span style="color: #009900;">&#41;</span>, y<span style="color: #339933;">:</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span><span style="color: #339933;">?</span> $subul.<span style="color: #006633;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">top</span><span style="color: #339933;">+</span>smoothmenu.<span style="color: #006633;">shadow</span>.<span style="color: #006633;">offsety</span> <span style="color: #339933;">:</span> $curobj.<span style="color: #006633;">position</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">top</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//store this shadow's offsets</span>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span><span style="color: #009900;">&#41;</span>
				$parentshadow<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span>document.<span style="color: #006633;">body</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
				var $parentLi<span style="color: #339933;">=</span>$curobj.<span style="color: #006633;">parents</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;li:eq(0)&quot;</span><span style="color: #009900;">&#41;</span>
				$parentshadow<span style="color: #339933;">=</span>$parentLi.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>.$shadow
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000000; font-weight: bold;">this</span>.$shadow<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;div class=&quot;ddshadow'</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span><span style="color: #339933;">?</span> <span style="color: #0000ff;">' toplevelshadow'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">'&quot;&gt;&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">prependTo</span><span style="color: #009900;">&#40;</span>$parentshadow<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>left<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">this</span>._shadowoffset.<span style="color: #006633;">x</span><span style="color: #339933;">+</span><span style="color: #0000ff;">'px'</span>, top<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">this</span>._shadowoffset.<span style="color: #006633;">y</span><span style="color: #339933;">+</span><span style="color: #0000ff;">'px'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>  <span style="color: #666666; font-style: italic;">//insert shadow DIV and set it to parent node for the next shadow div</span>
		<span style="color: #009900;">&#125;</span>
		$curobj.<span style="color: #006633;">hover</span><span style="color: #009900;">&#40;</span>
			function<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				var $targetul<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">children</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ul:eq(0)&quot;</span><span style="color: #009900;">&#41;</span>
				<span style="color: #000000; font-weight: bold;">this</span>._offsets<span style="color: #339933;">=</span><span style="color: #009900;">&#123;</span>left<span style="color: #339933;">:</span>$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">left</span>, top<span style="color: #339933;">:</span>$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">top</span><span style="color: #009900;">&#125;</span>
				var menuleft<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span> <span style="color: #339933;">&amp;&amp;</span> setting.<span style="color: #006633;">orientation</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">'v'</span><span style="color: #339933;">?</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">this</span>._dimensions.<span style="color: #006633;">w</span>
				menuleft<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>._offsets.<span style="color: #006633;">left</span><span style="color: #339933;">+</span>menuleft<span style="color: #339933;">+</span><span style="color: #000000; font-weight: bold;">this</span>._dimensions.<span style="color: #006633;">subulw</span><span style="color: #339933;">&gt;</span>$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span> <span style="color: #339933;">&amp;&amp;</span> setting.<span style="color: #006633;">orientation</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">'v'</span><span style="color: #339933;">?</span> <span style="color: #339933;">-</span><span style="color: #000000; font-weight: bold;">this</span>._dimensions.<span style="color: #006633;">subulw</span><span style="color: #339933;">+</span><span style="color: #000000; font-weight: bold;">this</span>._dimensions.<span style="color: #006633;">w</span> <span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #000000; font-weight: bold;">this</span>._dimensions.<span style="color: #006633;">w</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> menuleft <span style="color: #666666; font-style: italic;">//calculate this sub menu's offsets from its parent</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$targetul.<span style="color: #006633;">queue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">length</span><span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//if 1 or less queued animations</span>
					$targetul.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>left<span style="color: #339933;">:</span>menuleft<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;px&quot;</span>, width<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">this</span>._dimensions.<span style="color: #006633;">subulw</span><span style="color: #339933;">+</span><span style="color: #0000ff;">'px'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>height<span style="color: #339933;">:</span><span style="color: #0000ff;">'show'</span>,opacity<span style="color: #339933;">:</span><span style="color: #0000ff;">'show'</span><span style="color: #009900;">&#125;</span>, ddsmoothmenu.<span style="color: #006633;">transition</span>.<span style="color: #006633;">overtime</span><span style="color: #009900;">&#41;</span>
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>smoothmenu.<span style="color: #006633;">shadow</span>.<span style="color: #006633;">enabled</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						var shadowleft<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span><span style="color: #339933;">?</span> $targetul.<span style="color: #006633;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">left</span><span style="color: #339933;">+</span>ddsmoothmenu.<span style="color: #006633;">shadow</span>.<span style="color: #006633;">offsetx</span> <span style="color: #339933;">:</span> menuleft
						var shadowtop<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span><span style="color: #339933;">?</span>$targetul.<span style="color: #006633;">offset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">top</span><span style="color: #339933;">+</span>smoothmenu.<span style="color: #006633;">shadow</span>.<span style="color: #006633;">offsety</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">this</span>._shadowoffset.<span style="color: #006633;">y</span>
						<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span> <span style="color: #339933;">&amp;&amp;</span> ddsmoothmenu.<span style="color: #006633;">detectwebkit</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//in WebKit browsers, restore shadow's opacity to full</span>
							<span style="color: #000000; font-weight: bold;">this</span>.$shadow.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>opacity<span style="color: #339933;">:</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
						<span style="color: #009900;">&#125;</span>
						<span style="color: #000000; font-weight: bold;">this</span>.$shadow.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>overflow<span style="color: #339933;">:</span><span style="color: #0000ff;">''</span>, width<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">this</span>._dimensions.<span style="color: #006633;">subulw</span><span style="color: #339933;">+</span><span style="color: #0000ff;">'px'</span>, left<span style="color: #339933;">:</span>shadowleft<span style="color: #339933;">+</span><span style="color: #0000ff;">'px'</span>, top<span style="color: #339933;">:</span>shadowtop<span style="color: #339933;">+</span><span style="color: #0000ff;">'px'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>height<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">this</span>._dimensions.<span style="color: #006633;">subulh</span><span style="color: #339933;">+</span><span style="color: #0000ff;">'px'</span><span style="color: #009900;">&#125;</span>, ddsmoothmenu.<span style="color: #006633;">transition</span>.<span style="color: #006633;">overtime</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>,
			function<span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				var $targetul<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">children</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ul:eq(0)&quot;</span><span style="color: #009900;">&#41;</span>
				$targetul.<span style="color: #006633;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>height<span style="color: #339933;">:</span><span style="color: #0000ff;">'hide'</span>, opacity<span style="color: #339933;">:</span><span style="color: #0000ff;">'hide'</span><span style="color: #009900;">&#125;</span>, ddsmoothmenu.<span style="color: #006633;">transition</span>.<span style="color: #006633;">outtime</span><span style="color: #009900;">&#41;</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>smoothmenu.<span style="color: #006633;">shadow</span>.<span style="color: #006633;">enabled</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ddsmoothmenu.<span style="color: #006633;">detectwebkit</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//in WebKit browsers, set first child shadow's opacity to 0, as &quot;overflow:hidden&quot; doesn't work in them</span>
						<span style="color: #000000; font-weight: bold;">this</span>.$shadow.<span style="color: #006633;">children</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'div:eq(0)'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>opacity<span style="color: #339933;">:</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #000000; font-weight: bold;">this</span>.$shadow.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>overflow<span style="color: #339933;">:</span><span style="color: #0000ff;">'hidden'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>height<span style="color: #339933;">:</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#125;</span>, ddsmoothmenu.<span style="color: #006633;">transition</span>.<span style="color: #006633;">outtime</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//end hover</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//end $headers.each()</span>
	$mainmenu.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>display<span style="color: #339933;">:</span><span style="color: #0000ff;">'none'</span>, visibility<span style="color: #339933;">:</span><span style="color: #0000ff;">'visible'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>,
&nbsp;
init<span style="color: #339933;">:</span>function<span style="color: #009900;">&#40;</span>setting<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>typeof setting.<span style="color: #006633;">customtheme</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;object&quot;</span> <span style="color: #339933;">&amp;&amp;</span> setting.<span style="color: #006633;">customtheme</span>.<span style="color: #006633;">length</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//override default menu colors (default/hover) with custom set?</span>
		var mainmenuid<span style="color: #339933;">=</span><span style="color: #0000ff;">'#'</span><span style="color: #339933;">+</span>setting.<span style="color: #006633;">mainmenuid</span>
		var mainselector<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>setting.<span style="color: #006633;">orientation</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;v&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> mainmenuid <span style="color: #339933;">:</span> mainmenuid<span style="color: #339933;">+</span><span style="color: #0000ff;">', '</span><span style="color: #339933;">+</span>mainmenuid
		document.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&lt;style type=&quot;text/css&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>
			<span style="color: #339933;">+</span>mainselector<span style="color: #339933;">+</span><span style="color: #0000ff;">' ul li a {background:'</span><span style="color: #339933;">+</span>setting.<span style="color: #006633;">customtheme</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">';}<span style="color: #000099; font-weight: bold;">\n</span>'</span>
			<span style="color: #339933;">+</span>mainmenuid<span style="color: #339933;">+</span><span style="color: #0000ff;">' ul li a:hover {background:'</span><span style="color: #339933;">+</span>setting.<span style="color: #006633;">customtheme</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">';}<span style="color: #000099; font-weight: bold;">\n</span>'</span>
		<span style="color: #339933;">+</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">shadow</span>.<span style="color: #006633;">enabled</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span>document.<span style="color: #006633;">all</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>window.<span style="color: #006633;">XMLHttpRequest</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #000066; font-weight: bold;">false</span> <span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span> <span style="color: #666666; font-style: italic;">//in IE6, always disable shadow</span>
	jQuery<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">ready</span><span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//ajax menu?</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>typeof setting.<span style="color: #006633;">contentsource</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//if external ajax menu</span>
			ddsmoothmenu.<span style="color: #006633;">getajaxmenu</span><span style="color: #009900;">&#40;</span>$, setting<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//else if markup menu</span>
			ddsmoothmenu.<span style="color: #006633;">buildmenu</span><span style="color: #009900;">&#40;</span>$, setting<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">//end ddsmoothmenu variable</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Initialize Menu instance(s):</span>
&nbsp;
&nbsp;
ddsmoothmenu.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	mainmenuid<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;smoothmenu1&quot;</span>, <span style="color: #666666; font-style: italic;">//menu DIV id</span>
	orientation<span style="color: #339933;">:</span> <span style="color: #0000ff;">'h'</span>, <span style="color: #666666; font-style: italic;">//Horizontal or vertical menu: Set to &quot;h&quot; or &quot;v&quot;</span>
	classname<span style="color: #339933;">:</span> <span style="color: #0000ff;">'ddsmoothmenu'</span>, <span style="color: #666666; font-style: italic;">//class added to menu's outer DIV</span>
	<span style="color: #666666; font-style: italic;">//customtheme: [&quot;#1c5a80&quot;, &quot;#18374a&quot;],</span>
	contentsource<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;markup&quot;</span> <span style="color: #666666; font-style: italic;">//&quot;markup&quot; or [&quot;container_id&quot;, &quot;path_to_menu_file&quot;]</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
ddsmoothmenu.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	mainmenuid<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;smoothmenu2&quot;</span>, <span style="color: #666666; font-style: italic;">//Menu DIV id</span>
	orientation<span style="color: #339933;">:</span> <span style="color: #0000ff;">'v'</span>, <span style="color: #666666; font-style: italic;">//Horizontal or vertical menu: Set to &quot;h&quot; or &quot;v&quot;</span>
	classname<span style="color: #339933;">:</span> <span style="color: #0000ff;">'ddsmoothmenu-v'</span>, <span style="color: #666666; font-style: italic;">//class added to menu's outer DIV</span>
	<span style="color: #666666; font-style: italic;">//customtheme: [&quot;#804000&quot;, &quot;#482400&quot;],</span>
	contentsource<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;markup&quot;</span> <span style="color: #666666; font-style: italic;">//&quot;markup&quot; or [&quot;container_id&quot;, &quot;path_to_menu_file&quot;]</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>head<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;</span>Example <span style="color: #cc66cc;">1</span><span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;smoothmenu1&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;ddsmoothmenu&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.digau.cn&quot;</span><span style="color: #339933;">&gt;</span>Item <span style="color: #cc66cc;">1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Folder <span style="color: #cc66cc;">0</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.3</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.4</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.3</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.4</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Folder <span style="color: #cc66cc;">1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.3</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.4</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.3</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.4</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Item <span style="color: #cc66cc;">3</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Folder <span style="color: #cc66cc;">2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">2.1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Folder <span style="color: #cc66cc;">2.1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 2.1.1<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 2.1.2<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Folder 3.1.1<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 3.1.1.1<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 3.1.1.2<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 3.1.1.3<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 3.1.1.4<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 3.1.1.5<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 2.1.4<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.digau.cn&quot;</span><span style="color: #339933;">&gt;</span>Item <span style="color: #cc66cc;">4</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>br style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;clear: left&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span>
&nbsp;
&nbsp;
<span style="color: #339933;">&lt;</span>h2 style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;margin-top:200px&quot;</span><span style="color: #339933;">&gt;</span>Example <span style="color: #cc66cc;">2</span><span style="color: #339933;">&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;smoothmenu2&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;ddsmoothmenu-v&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.digau.cn&quot;</span><span style="color: #339933;">&gt;</span>Item <span style="color: #cc66cc;">1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Folder <span style="color: #cc66cc;">0</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.3</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.4</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.3</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.4</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Folder <span style="color: #cc66cc;">1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.3</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.4</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.3</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">1.4</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Item <span style="color: #cc66cc;">3</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Folder <span style="color: #cc66cc;">2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item <span style="color: #cc66cc;">2.1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Folder <span style="color: #cc66cc;">2.1</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 2.1.1<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 2.1.2<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Folder 3.1.1<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;</span>ul<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 3.1.1.1<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 3.1.1.2<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 3.1.1.3<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 3.1.1.4<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    		<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 3.1.1.5<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
		<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;#&quot;</span><span style="color: #339933;">&gt;</span>Sub Item 2.1.4<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
    <span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
  <span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.digau.cn&quot;</span><span style="color: #339933;">&gt;</span>Item <span style="color: #cc66cc;">4</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;&lt;/</span>li<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>br style<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;clear: left&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #003399;">Collection</span> by <span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://digau.cn&quot;</span><span style="color: #339933;">&gt;</span>digAu.<span style="color: #006633;">cn</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;&lt;/</span>body<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span></pre></div></div>

<p>本例还可以给有子菜单的项加上标记，查找</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//arrowimages: {down:['downarrowclass', 'down.gif', 23], right:['rightarrowclass', 'right.gif']},you can edit this row</span></pre></div></div>

<p>改成</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">arrowimages<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>down<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'downarrowclass'</span>, <span style="color: #0000ff;">'down.gif'</span>, <span style="color: #cc66cc;">23</span><span style="color: #009900;">&#93;</span>, right<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rightarrowclass'</span>, <span style="color: #0000ff;">'right.gif'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>再查找</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">		<span style="color: #666666; font-style: italic;">//$curobj.children(&quot;a:eq(0)&quot;).css(this.istopheader? {paddingRight: smoothmenu.arrowimages.down[2]} : {}).append( //add arrow images</span>
			<span style="color: #666666; font-style: italic;">//'&lt;img src=&quot;'+ (this.istopheader &amp;&amp; setting.orientation!='v'? smoothmenu.arrowimages.down[1] : smoothmenu.arrowimages.right[1])</span>
			<span style="color: #666666; font-style: italic;">//+'&quot; class=&quot;' + (this.istopheader &amp;&amp; setting.orientation!='v'? smoothmenu.arrowimages.down[0] : smoothmenu.arrowimages.right[0])</span>
			<span style="color: #666666; font-style: italic;">//+ '&quot; style=&quot;border:0;&quot; /&gt;'</span>
		<span style="color: #666666; font-style: italic;">//)</span></pre></div></div>

<p>改成</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">		$curobj.<span style="color: #006633;">children</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a:eq(0)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">css</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#123;</span>paddingRight<span style="color: #339933;">:</span> smoothmenu.<span style="color: #006633;">arrowimages</span>.<span style="color: #006633;">down</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span> <span style="color: #666666; font-style: italic;">//add arrow images</span>
			<span style="color: #0000ff;">'&lt;img src=&quot;'</span><span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span> <span style="color: #339933;">&amp;&amp;</span> setting.<span style="color: #006633;">orientation</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">'v'</span><span style="color: #339933;">?</span> smoothmenu.<span style="color: #006633;">arrowimages</span>.<span style="color: #006633;">down</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> smoothmenu.<span style="color: #006633;">arrowimages</span>.<span style="color: #006633;">right</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">+</span><span style="color: #0000ff;">'&quot; class=&quot;'</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">istopheader</span> <span style="color: #339933;">&amp;&amp;</span> setting.<span style="color: #006633;">orientation</span><span style="color: #339933;">!=</span><span style="color: #0000ff;">'v'</span><span style="color: #339933;">?</span> smoothmenu.<span style="color: #006633;">arrowimages</span>.<span style="color: #006633;">down</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> smoothmenu.<span style="color: #006633;">arrowimages</span>.<span style="color: #006633;">right</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">+</span> <span style="color: #0000ff;">'&quot; style=&quot;border:0;&quot; /&gt;'</span>
		<span style="color: #009900;">&#41;</span></pre></div></div>

<p>这样需要一个右箭头和一个下箭头共两个图片，可以自己去找。</p>
<p  class="related_post_title">Related Posts</p><ul class="related_post"><li><a href="http://blog.imbolo.com/create-a-simple-ajax-rss-widget-with-jquery-and-yahoo-pipes/" title="利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件">利用 Yahoo Pipes 和 jQuery 做一个 RSS 挂件</a></li><li><a href="http://blog.imbolo.com/jquery-jwtabs/" title="jQuery插件：jwTabs">jQuery插件：jwTabs</a></li><li><a href="http://blog.imbolo.com/make-a-jquery-style-switch/" title="用jQuery制作页面风格切换开关">用jQuery制作页面风格切换开关</a></li><li><a href="http://blog.imbolo.com/make-ajax-with-jquery/" title="使用 jQuery 简化 Ajax 开发">使用 jQuery 简化 Ajax 开发</a></li><li><a href="http://blog.imbolo.com/make-a-door-effect-in-jquery-and-css/" title="jQuery+CSS制作滑动门效果">jQuery+CSS制作滑动门效果</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.imbolo.com/make-a-dropdown-menu-in-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
