<?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>四眼天兔工作室 &#187; jQuery</title>
	<atom:link href="http://www.4ebstudio.com/category/tips/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://www.4ebstudio.com</link>
	<description>网站建设｜Joomla｜Wordpress｜PSD转HTML｜VI｜平面广告</description>
	<lastBuildDate>Tue, 29 Jun 2010 09:18:16 +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>10个极具创意的用户交互界面及其制作方法</title>
		<link>http://www.4ebstudio.com/10-creative-rich-ui-interfaces-how-to-create-them.html</link>
		<comments>http://www.4ebstudio.com/10-creative-rich-ui-interfaces-how-to-create-them.html#comments</comments>
		<pubDate>Mon, 30 Mar 2009 05:53:40 +0000</pubDate>
		<dc:creator>4EB Studio</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[天兔贴士]]></category>
		<category><![CDATA[网页设计]]></category>
		<category><![CDATA[设计教程]]></category>
		<category><![CDATA[设计灵感]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[动态菜单]]></category>
		<category><![CDATA[折叠版]]></category>
		<category><![CDATA[滑动版]]></category>
		<category><![CDATA[网页特效]]></category>
		<category><![CDATA[表单美化]]></category>

		<guid isPermaLink="false">http://4ebstudio.com/?p=82</guid>
		<description><![CDATA[
用户体验在近几年得到了迅速的改善，主要体现在丰富的的用户交互界面上。AJAX, javascript以及CSS的广泛应用为用户提供了先进的，尖端的以及专业的动态交互界面解决方案。
之前已经有了很多文章来介绍一些令人惊叹的 javascript, Ajax和CSS技术以及哪里可以找到这些技术的使用方法。今天，我们将来看看10个极具创意且UI界面功能丰富的网站，以及如何使用文中提到的技术来制作类似的交互效果。
1. Alex Buga (滑移，可拖动的页脚以及动态按钮)

在这个绝对难以置信的设计中你会看到:


1.1 一个具有美观的动态悬浮效果的菜单
制作方法 » 使用超级弹性特效制作极具视觉冲击的网页菜单
该教程讲解了如何使用几行Javascript代码以及MooTools库来设计一个令人振奋的弹性菜单。

查看演示
1.2 滑动的文章显示面板
制作方法 » 漂亮的动态周线表
该教程向你讲述了如何设计一款带美观的，带有每日注释的动态周记，你可以在你的网站中使用该方法进行自定义设置。

查看演示
1.3 可以拖动的页脚
制作方法 » 事件委派表中的拖拽以及调整大小
只有父元素在控制事件。在本例中将由编辑容器内的元素来控制事件。如果你向你的容其中添加动态的元素，你无需再附上任何事件。

查看演示
2. Ricoverdeo (幻灯效果)

一个非常简洁的滑动效果，并且使用了大量的插图作为辅助。

2.1 在悬浮元素上添加简单的滑动效果
制作方法 » Easy Slider 1.5 &#8211; 简单的制作图片与内容滑动的jQuery插件
Easy Slider (我对这款插件的叫法)可以使图片或者任何内容通过点击或自动在水平或垂直方向上滑动。主要特性包括：连续滑动，“go to first”和&#8221;go to last&#8221;按钮，隐藏控制工具，可选的控制按钮的代码标记，在同一页面上垂直滑动或出现多多种滑动。

查看演示
3. jasonreedwebdesign (滑动标签，折叠面板)

Jason Reed在他的个人作品集上使用了一款流行的折叠面板效果允许用户进行页面导航。他还在折叠面板内使用了一款非常漂亮的滑动标签来增强界面结构。

3.1 互动标签
制作方法 » 自动滑动标签
滑动标签是一个mootools插件，可以添加一些漂亮简洁的效果。它和Panic Software&#8217;s Coda网站上的滑动效果相似。另外，它还可以在固定的时间间隔内自动滑移。

查看演示
3.2 折叠面板
制作方法 » 垂直折叠面板
该款插件提供了一些简单的选项来改变折叠面板的外观和动作。

制作方法 » 使用Mootools制作折叠面板


4. Dragon Interactive (动态菜单)

我非常喜欢他那叹为观止的菜单，乍一看以为是一个flash，后来通过查看代码发现就是使用了简单的XHTML，CSS以及Javascript。

3.1 动态菜单
制作方法» 使用jQuery制作动态菜单

查看演示

5. DesignShack (切换页面布局)

大多数CSS图库网站都会提供给用户改变页面布局的功能，从而使用户可以更加轻松，迅速的获取信息。 ƒ

5.1 转换页面外观
制作方法 » 使用CSS和jQuery显示转换钮
通过使用CSS和jQuery让用户切换页面布局。

查看演示

6. Profoto (面包屑Breadcrumbs)

Profoto有一个独特的面包屑(breadcrumb)菜单。点击面包屑链接的时候会在它的下方打开一个区域，给用户一些附加属性进行选择。

6.1 面包屑Breadcrumb
制作方法 » jBreadCrumb
jBreadCrumb是一款jQuery插件，可以通过更为灵活和聪明的方式来显示面包屑 。

查看演示

7. Shelfari [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>用户体验在近几年得到了迅速的改善，主要体现在丰富的的用户交互界面上。AJAX, javascript以及CSS的广泛应用为用户提供了先进的，尖端的以及专业的动态交互界面解决方案。</p>
<p>之前已经有了很多文章来介绍一些令人惊叹的 javascript, Ajax和CSS技术以及哪里可以找到这些技术的使用方法。今天，我们将来看看10个极具创意且UI界面功能丰富的网站，以及如何使用文中提到的技术来制作类似的交互效果。</p>
<h4 style="font-size: 1em;">1. <a href="http://www.alexbuga.com/v8/">Alex Buga (滑移</a><a href="http://www.alexbuga.com/v8/">，可拖动的页脚</a><a href="http://www.alexbuga.com/v8/">以及动态按钮)</a></h4>
<p><a href="http://www.alexbuga.com/v8/"></a><a href="http://www.alexbuga.com/v8/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_1.jpg" alt="Creative &amp; Rich UI interfaces" /></a><br />
在这个绝对难以置信的设计中你会看到:</p>
<p><span id="more-82"></span></p>
<ul>
<li><strong>1.1 一个具有美观的动态悬浮效果的菜单</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://woork.blogspot.com/2008/12/super-elastic-effect-to-design-high.html">使用超级弹性特效制作极具视觉冲击的网页菜单</a></h5>
<p>该教程讲解了如何使用几行Javascript代码以及MooTools库来设计一个令人振奋的弹性菜单。</p>
<p><a href="http://woork.blogspot.com/2008/12/super-elastic-effect-to-design-high.html"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_1_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://woorktuts.110mb.com/elasticmenu-mootools/index.html">查看演示</a></p>
<li><strong>1.2 滑动的文章显示面板</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://woork.blogspot.com/2009/01/elegant-animated-weekly-timeline-for.html">漂亮的动态周线表</a></h5>
<p>该教程向你讲述了如何设计一款带美观的，带有每日注释的动态周记，你可以在你的网站中使用该方法进行自定义设置。</p>
<p><a href="http://woork.blogspot.com/2009/01/elegant-animated-weekly-timeline-for.html"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_1_3.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://woorktuts.110mb.com/weeklytimeline/timeline.html">查看演示</a></p>
<li><strong>1.3 可以拖动的页脚</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://batiste.dosimple.ch/blog/2008-05-18-1/">事件委派表中的拖拽以及调整大小</a></h5>
<p>只有父元素在控制事件。在本例中将由编辑容器内的元素来控制事件。如果你向你的容其中添加动态的元素，你无需再附上任何事件。</p>
<p><a href="http://batiste.dosimple.ch/blog/2008-05-18-1/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_1_4.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://batiste.dosimple.ch/blog/posts/2008-05-18-1/jquery-drag-and-drop-and-resize-event-delegation.html">查看演示</a></ul>
<h4 style="font-size: 1em;">2. <a href="http://www.ricoverdeo.com/">Ricoverdeo (幻灯效果)</a></h4>
<p><a href="http://www.ricoverdeo.com/"></a><a href="http://www.ricoverdeo.com/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a><br />
一个非常简洁的滑动效果，并且使用了大量的插图作为辅助。</p>
<ul>
<li><strong>2.1 在悬浮元素上添加简单的滑动效果</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding">Easy Slider 1.5 &#8211; 简单的制作图片与内容滑动的jQuery插件</a></h5>
<p>Easy Slider (我对这款插件的叫法)可以使图片或者任何内容通过点击或自动在水平或垂直方向上滑动。主要特性包括：连续滑动，“go to first”和&#8221;go to last&#8221;按钮，隐藏控制工具，可选的控制按钮的代码标记，在同一页面上垂直滑动或出现多多种滑动。</p>
<p><a href="http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_1_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://cssglobe.com/lab/easyslider1.5/05.html">查看演示</a></ul>
<h4 style="font-size: 1em;">3. <a href="http://www.jasonreedwebdesign.com/">jasonreedwebdesign (滑动标签，折叠面板)</a></p>
<p><a href="http://www.jasonreedwebdesign.com/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_3.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p>Jason Reed在他的个人作品集上使用了一款流行的折叠面板效果允许用户进行页面导航。他还在折叠面板内使用了一款非常漂亮的滑动标签来增强界面结构。</p>
<ul>
<li><strong>3.1 互动标签</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://creativepony.com/journal/scripts/auto-sliding-tabs/">自动滑动标签</a></h5>
<p>滑动标签是一个mootools插件，可以添加一些漂亮简洁的效果。它和Panic Software&#8217;s Coda网站上的滑动效果相似。另外，它还可以在固定的时间间隔内自动滑移。</p>
<p><a href="http://creativepony.com/journal/scripts/auto-sliding-tabs/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/t2.gif" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://creativepony.com/demos/auto-sliding-tabs/">查看演示</a></p>
<li><strong>3.2 折叠面板</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://dev.portalzine.de/index?/Horizontal_Accordion--print">垂直折叠面板</a></h5>
<p>该款插件提供了一些简单的选项来改变折叠面板的外观和动作。</p>
<p><a href="http://dev.portalzine.de/index?/Horizontal_Accordion--print"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/j-5.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://www.nyokiglitter.com/tutorials/horizontal.html">使用</a><a href="http://www.nyokiglitter.com/tutorials/horizontal.html">Mootools</a><a href="http://www.nyokiglitter.com/tutorials/horizontal.html">制作折叠面板</a></h5>
<p><a href="http://www.nyokiglitter.com/tutorials/horizontal.html"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_3_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a></ul>
</h4>
<h4 style="font-size: 1em;">4. <a href="http://www.dragoninteractive.com/">Dragon Interactive (动态菜单)</a></p>
<p><a href="http://www.dragoninteractive.com/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_4.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p>我非常喜欢他那叹为观止的菜单，乍一看以为是一个flash，后来通过查看代码发现就是使用了简单的XHTML，CSS以及Javascript。</p>
<ul>
<li><strong>3.1 动态菜单</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法»</strong> <a href="http://www.shopdev.co.uk/blog/animated-menus-using-jquery/">使用jQuery</a><a href="http://www.shopdev.co.uk/blog/animated-menus-using-jquery/">制作动态菜单</a></h5>
<p><a href="http://www.shopdev.co.uk/blog/animated-menus-using-jquery/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_4_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://www.shopdev.co.uk/blog/menuDemo.html">查看演示</a></ul>
</h4>
<h4 style="font-size: 1em;">5. <a href="http://designshack.co.uk/gallery/">DesignShack (切换页面布局)</a></p>
<p><a href="http://designshack.co.uk/gallery/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_5.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p>大多数CSS图库网站都会提供给用户改变页面布局的功能，从而使用户可以更加轻松，迅速的获取信息。 ƒ</p>
<ul>
<li><strong>5.1 转换页面外观</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://designm.ag/tutorials/jquery-display-switch/">使用CSS和jQuery显示转换钮</a></h5>
<p>通过使用CSS和jQuery让用户切换页面布局。</p>
<p><a href="http://designm.ag/tutorials/jquery-display-switch/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_5_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://www.sohtanaka.com/web-design/examples/display-switch/">查看演示</a></ul>
</h4>
<h4 style="font-size: 1em;">6. <a href="http://www.profoto.com/products/profoto/lightshapingtools">Profoto (面包屑Breadcrumbs)</a></p>
<p><a href="http://www.profoto.com/products/profoto/lightshapingtools"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_6.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p>Profoto有一个独特的面包屑(breadcrumb)菜单。点击面包屑链接的时候会在它的下方打开一个区域，给用户一些附加属性进行选择。</p>
<ul>
<li><strong>6.1 面包屑Breadcrumb</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://www.comparenetworks.com/developers/jqueryplugins/jbreadcrumb.html">jBreadCrumb</a></h5>
<p>jBreadCrumb是一款jQuery插件，可以通过更为灵活和聪明的方式来显示面包屑 。</p>
<p><a href="http://www.comparenetworks.com/developers/jqueryplugins/jbreadcrumb.html"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_6_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://www.comparenetworks.com/developers/jqueryplugins/jbreadcrumb.html">查看演示</a></ul>
</h4>
<h4 style="font-size: 1em;">7. <a href="http://www.shelfari.com/">Shelfari (混合按钮)</a></p>
<p><a href="http://www.shelfari.com/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_7.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p>Shelfari具有一个非常有趣的混合按钮/向下滑移的菜单来显示对书籍的执行动作。如果你查看代码你会发现选择框那里并没有使用一个输入框，而仅仅使用了背景图片。</p>
<ul>
<li><strong>7.1 自定义表单元素</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法»</strong> <a href="http://customformelements.net/">Custom Form Elements</a></h5>
<p>曾经总是在好奇如何可以按照自己的方式定义表单元素，如选择框，多选框以及选择区域。Custom Form Elements通过使用Javascript和CSS来提升基于网页的XHMTL表单的样式及可用性。</p>
<p><a href="http://customformelements.net/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_7_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://customformelements.net/demopage.php">查看演示</a></ul>
</h4>
<h4 style="font-size: 1em;">8. <a style="text-decoration: none;" href="http://www.cssninjas.com/order">CSS Ninjas (费用预估滑杆)</a></p>
<p><a href="http://www.cssninjas.com/order"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_8.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p>CSS Ninjas提供了一个非常有趣的费用预估滑杆允许客户估算服务费用。</p>
<ul>
<li><strong>8.1 滑杆</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://www.filamentgroup.com/lab/update_jquery_ui_16_slider_from_a_select_element/">jQuery UI 1.7 Slider</a></h5>
<p>该款插件的目的就是通过渐进增强来控制jQuery UI Slider插件。</p>
<p><a href="http://www.filamentgroup.com/lab/update_jquery_ui_16_slider_from_a_select_element/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_8_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://www.filamentgroup.com/examples/slider_v2/index3.php">查看演示</a></ul>
</h4>
<h4 style="font-size: 1em;">9. <a style="text-decoration: none;" href="http://www.facebook.com/inbox/?compose">Facebook (表单自动完成)</a></p>
<p><a href="http://www.facebook.com/inbox/?compose"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_9.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p>Facebook的地址自动完成表单是表单自动完成的最好案例。</p>
<ul>
<li><strong>9.1 表单自动完成</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://www.emposha.com/javascript/jquery/jquerymultiselect.html">FCBKcomplete v 1.09</a></h5>
<p>一款有趣的facebook样式的动态输入框，可以自动完成或预载值。</p>
<p><a href="http://www.emposha.com/javascript/jquery/jquerymultiselect.html"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_9_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://www.emposha.com/demo/fcbkcomplete/">查看演示</a></ul>
</h4>
<h4 style="font-size: 1em;">10. <a style="text-decoration: none;" href="http://www.designflavr.com/">Design Flavr (Smooth Slideshow)</a></p>
<p><a href="http://www.designflavr.com/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_10.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p>DesignFlavr, 一个非常有名的设计灵感资源网站，使用了一个淡入淡出的幻灯效果来展示他们的特色作品以及相应的作品描述。</p>
<ul>
<li><strong>10.1 Smooth Slide</strong></li>
<h5 style="font-size: 0.83em;"><strong>制作方法 »</strong> <a href="http://www.serie3.info/s3slider/">s3Slider</a></h5>
<p>s3Slider是一款免费的jQuery插件，可以实现交互渐变的幻灯效果。</p>
<p><a href="http://www.serie3.info/s3slider/"><img style="border: 0px initial initial;" src="http://4ebstudio.com/wp-content/uploads/2009/03/rich_ui_10_2.jpg" alt="Creative &amp; Rich UI interfaces" /></a></p>
<p><a href="http://www.serie3.info/s3slider/demonstration.html">查看演示</a></ul>
<div><span style="font-weight: normal;">[</span><a href="http://www.noupe.com/design/10-creative-rich-ui-interfaces-how-to-create-them.html"><span style="font-weight: normal;">原文链接</span></a><span style="font-weight: normal;">]</span></div>
</h4>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.4ebstudio.com/10-creative-rich-ui-interfaces-how-to-create-them.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>15个网站加速，代码优化的技巧</title>
		<link>http://www.4ebstudio.com/15-tips-to-speed-up-your-website-and-optimize-your-code.html</link>
		<comments>http://www.4ebstudio.com/15-tips-to-speed-up-your-website-and-optimize-your-code.html#comments</comments>
		<pubDate>Tue, 27 Jan 2009 05:50:12 +0000</pubDate>
		<dc:creator>4EB Studio</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[天兔贴士]]></category>
		<category><![CDATA[实用工具]]></category>
		<category><![CDATA[网页设计]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[网站工具]]></category>

		<guid isPermaLink="false">http://4ebstudio.com/?p=78</guid>
		<description><![CDATA[将图片压缩到最小

当我们使用photoshop“存储成网页格式”的选项时，我们可以将图片文件压缩的小一些。但是，你是否知道这些图片大小可以被压缩的更多而不降低图片质量呢？有个名叫Smush.It 的网站可以帮助你实现这一点。

学会擅用Snippets

许多的IDE是都提供&#8221;code snippet&#8221; 控制面板允许你存储一些代码以备后用。你是否发现自己经常会去lipsum.com获取一些常用本文呢？那为什么不试试使用snippet？在Dreamweaver中，按下&#8221;Shift+F9&#8243;键即可打开snippet标签。你可以将需要的snippet托拽到任何你需要的地方。这个方法将节省你的大量时间。
利用Console.log()进行调试

你或许下载了一个jQuery库，并且在试图掌握它的语法结构。同样，你可能遇到了一些困难并且意识到你无法确认变量的对应值。没关系，你可以这样做：
键入命令：
console.log($someVariable);
现在，打开Firefox（请确认你已安装了FireBug），然后点击F12。你将会看到你正在查找的变量所对应的值。
下载网页开发工具

这是一款由Chris Pederick 开发的，非常实用的Firefox扩展插件，具有很多选项。或许你们大多数看过我视频教程的人都会发现我非常喜欢使用&#8221;Edit CSS&#8221; 这个选项来实时调整我的样式表。该工具的其他功能包括：

轻松禁用Javascript
轻松禁用CSS
快速HTML/CSS验证链接
标尺
禁用cookies
还有其他一系列很多伟大的功能

Web Developer Toolbar
将Script标签放置到页面最底端

我们似乎很少这样做。虽然它并非总是适宜，但是你的确可以通过把script标签放到&#60;body&#62;标签后来提高网站速度很多倍。
....





大多数现代浏览器在同一台服务器上最多同时加载两个内容。但是，当你加载脚本文件的时候，其他的都不会被同时加载。因此，只要情况允许的话，最好将你的脚本文件移动到文件最底端，以便让服务器先加载其他内容（如图片，css等）。
压缩CSS和Javascript文件

如果网站的性能最你来说最重要的话，我强烈建议你考虑在展开之前压缩CSS和Javascript文件。在开发之前不要嫌它麻烦，这会对你非常有帮助的。
Javascript压缩服务

Javascript Compressor
JS Compressor

CSS压缩服务

CSS Optimiser
CSS Compressor
Clean CSS

另外两个有用的JavaScript压缩工具是 YUI Compressor, 和 JSMin.
jQuery贴士集

不久前，tvidesign.co.uk的Jon Hobbs-Smith发表了一篇非常棒的文章详述了jQuery的25个实用技巧。请确保将该页面收藏了。这里列举了我非常喜欢用的一些技巧。
检查元素是否已经存在？
if ($(’#myDiv).length) {
// this code will only run if the div with an id of #myDiv exists.
}



使用Context
很多人都没有意识到这一点，当访问dom元素的时候，jQuery函数会接受第二个参数 &#8211; &#8220;context&#8221;。请往下看：
var myElement = $('#someElement');



该代码将命令jQuery越过整个dom。我们可以通过使用context作为第二个参数来加速网站。
var myElement = $('#someElement', $('.someContainer'));



现在我们将告诉jQuery仅搜索.someContainer 内的元素，并且或略所有该元素以外的东西。
使用ID代替Class
当用jQuery访问ID的时候，通常会使用传统的&#8221;getElementById&#8221;方式。但是，当访问class元素的时候，jQuery必须使用他自己的方式跨越整个dom，结果这样会花费更长的时间。
产看所有25个技巧!
尽可能使用$_GET代替 $_POST

如果在编写Ajax命令的时候，你可以在$_GET 或者$_POST之间选择的话，那么请选择前者。
&#8221; Yahoo! Mail团队发现，当使用XMLHttp请求的时候，POST在浏览器中会通过两个步骤实现：首先发送header，然后再发送数据。因此最好使用GET，它仅使用一个TCP数据分组（除非你有非常多的cookies）。&#8221; &#8211; Developer.Yahoo.com
请记住：不要轻率的使用$_GET。请先弄清楚你第一步要作什么。
适时使用Library和Framework

无论你使用PHP, ASP.NET, Mootools, jQuery，或他们中的多种，请考虑适时的使用架构。
例如:

如果我要在网站上运行一个简单的静态页面，仅需要一个小的Javascript来实现翻转效果，那么使用jQuery的话就不太合适了。
如果我的静态网站的大多数特性被放在一个XML文件中，我就不需要使用架构。否则，我将会网站额外的带宽付出许多费用。

但是，如果我正在建设一个负责的网站，需要一个完整的CMS系统和复杂的数据访问，那么我将会使用一些我常用的架构。
请记住：架构仅仅是在需要的时候才会为你服务，否则请慎用。
YSlow

YSlow是一款非常棒的工具可以帮助你检查网站的有效性。
这里有一个很好的 YSlow视频教程 来讲述该款工具的实用性。我强烈推荐你有机会看一看。

学会使用键盘快捷键

大多数有经验的设计师/开发人员都会同意我的观点，如果我要实现网站或者设计的一个变化我都要去工具栏里面寻找相应的菜单，那会浪费我很多时间。我已经使用快捷键很长时间了，以至于我根本不知道这些命令的正确菜单位置。我就知道&#8221;Shift + [...]]]></description>
			<content:encoded><![CDATA[<h3 style="font-size: 1.17em;">将图片压缩到最小</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/smushIT.png" alt="compress images" /></div>
<p>当我们使用photoshop“存储成网页格式”的选项时，我们可以将图片文件压缩的小一些。但是，你是否知道这些图片大小可以被压缩的更多而不降低图片质量呢？有个名叫<a href="http://www.smush.it/">Smush.It</a> 的网站可以帮助你实现这一点。</p>
<p><span id="more-78"></span></p>
<h3 style="font-size: 1.17em;">学会擅用Snippets</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/dreamweaverSnippets.png" alt="snippets" /></div>
<p>许多的IDE是都提供&#8221;code snippet&#8221; 控制面板允许你存储一些代码以备后用。你是否发现自己经常会去lipsum.com获取一些常用本文呢？那为什么不试试使用snippet？在Dreamweaver中，按下&#8221;Shift+F9&#8243;键即可打开snippet标签。你可以将需要的snippet托拽到任何你需要的地方。这个方法将节省你的大量时间。</p>
<h3 style="font-size: 1.17em;">利用Console.log()进行调试</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/consoleLog.png" alt="console.log" /></div>
<p>你或许下载了一个jQuery库，并且在试图掌握它的语法结构。同样，你可能遇到了一些困难并且意识到你无法确认变量的对应值。没关系，你可以这样做：</p>
<p>键入命令：</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="javascript">console.log($someVariable);</pre>
<p>现在，打开Firefox（请确认你已安装了<a href="https://addons.mozilla.org/firefox/addon/1843">FireBug</a>），然后点击F12。你将会看到你正在查找的变量所对应的值。</p>
<h3 style="font-size: 1.17em;">下载网页开发工具</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/webdevelopertollbar.png" alt="web developer toolbar" /></div>
<p>这是一款由<a href="http://chrispederick.com/">Chris Pederick</a> 开发的，非常实用的Firefox扩展插件，具有很多选项。或许你们大多数看过我视频教程的人都会发现我非常喜欢使用&#8221;Edit CSS&#8221; 这个选项来实时调整我的样式表。该工具的其他功能包括：</p>
<ul>
<li>轻松禁用Javascript</li>
<li>轻松禁用CSS</li>
<li>快速HTML/CSS验证链接</li>
<li>标尺</li>
<li>禁用cookies</li>
<li>还有其他一系列很多伟大的功能</li>
</ul>
<p><a href="https://addons.mozilla.org/firefox/addon/60">Web Developer Toolbar</a></p>
<h3 style="font-size: 1.17em;">将Script标签放置到页面最底端</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/scriptTagsBottom.png" alt="snippets" /></div>
<p>我们似乎很少这样做。虽然它并非总是适宜，但是你的确可以通过把script标签放到&lt;body&gt;标签后来提高网站速度很多倍。</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="html4strict">....</pre>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="html4strict"><script src="someScript.js" type="text/javascript"><!--mce:0--></script></pre>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="html4strict"><script src="anotherScript.js" type="text/javascript"><!--mce:1--></script></pre>
<table style="cursor: default; border: 1px dashed #bbbbbb;" border="0">
<tbody></tbody>
</table>
<h4 style="font-size: 1em;"><span style="font-weight: normal;">大多数现代浏览器在同一台服务器上最多同时加载两个内容。但是，当你加载脚本文件的时候，其他的都不会被同时加载。因此，只要情况允许的话，最好将你的脚本文件移动到文件最底端，以便让服务器先加载其他内容（如图片，css等）。</span></h4>
<h3 style="font-size: 1.17em;">压缩CSS和Javascript文件</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/javascriptCompress.png" alt="compress files" /></div>
<p>如果网站的性能最你来说最重要的话，我强烈建议你考虑在展开之前压缩CSS和Javascript文件。在开发之前不要嫌它麻烦，这会对你非常有帮助的。</p>
<h4 style="font-size: 1em;">Javascript压缩服务</h4>
<ul>
<li><a href="http://javascriptcompressor.com/">Javascript Compressor</a></li>
<li><a href="http://www.xmlforasp.net/JSCompressor.aspx">JS Compressor</a></li>
</ul>
<h4 style="font-size: 1em;">CSS压缩服务</h4>
<ul>
<li><a href="http://www.cssoptimiser.com/">CSS Optimiser</a></li>
<li><a href="http://www.cssdrive.com/index.php/main/csscompressor/">CSS Compressor</a></li>
<li><a href="http://www.cleancss.com/">Clean CSS</a></li>
</ul>
<p>另外两个有用的JavaScript压缩工具是 <a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a>, 和 <a href="http://crockford.com/javascript/jsmin">JSMin</a>.</p>
<h3 style="font-size: 1.17em;">jQuery贴士集</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/jQuery.png" alt="jQuery Tips" /></div>
<p>不久前，<a href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx">tvidesign.co.uk</a>的Jon Hobbs-Smith发表了一篇非常棒的文章详述了jQuery的25个实用技巧。请确保将该页面收藏了。这里列举了我非常喜欢用的一些技巧。</p>
<h4 style="font-size: 1em;">检查元素是否已经存在？</h4>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="javascript">if ($(’#myDiv).length) {</pre>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="javascript">// this code will only run if the div with an id of #myDiv exists.</pre>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="javascript">}</pre>
<table style="cursor: default; border: 1px dashed #bbbbbb;" border="0">
<tbody></tbody>
</table>
<h4 style="font-size: 1em;">使用Context</h4>
<p>很多人都没有意识到这一点，当访问dom元素的时候，jQuery函数会接受第二个参数 &#8211; &#8220;context&#8221;。请往下看：</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="javascript">var myElement = $('#someElement');</pre>
<table style="cursor: default; border: 1px dashed #bbbbbb;" border="0">
<tbody></tbody>
</table>
<p>该代码将命令jQuery越过整个dom。我们可以通过使用context作为第二个参数来加速网站。</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="javascript">var myElement = $('#someElement', $('.someContainer'));</pre>
<table style="cursor: default; border: 1px dashed #bbbbbb;" border="0">
<tbody></tbody>
</table>
<p>现在我们将告诉jQuery仅搜索.someContainer 内的元素，并且或略所有该元素以外的东西。</p>
<h4 style="font-size: 1em;">使用ID代替Class</h4>
<p>当用jQuery访问ID的时候，通常会使用传统的&#8221;getElementById&#8221;方式。但是，当访问class元素的时候，jQuery必须使用他自己的方式跨越整个dom，结果这样会花费更长的时间。</p>
<p><a href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx">产看所有25个技巧!</a></p>
<h3 style="font-size: 1.17em;">尽可能使用$_GET代替 $_POST</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/querystrings.png" alt="querystrings" /></div>
<p>如果在编写Ajax命令的时候，你可以在$_GET 或者$_POST之间选择的话，那么请选择前者。</p>
<blockquote><p>&#8221; Yahoo! Mail团队发现，当使用XMLHttp请求的时候，POST在浏览器中会通过两个步骤实现：首先发送header，然后再发送数据。因此最好使用GET，它仅使用一个TCP数据分组（除非你有非常多的cookies）。&#8221; &#8211; Developer.Yahoo.com</p></blockquote>
<p>请记住：不要轻率的使用$_GET。请先弄清楚你第一步要作什么。</p>
<h3 style="font-size: 1.17em;">适时使用Library和Framework</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/frameworks.png" alt="use frameworks" /></div>
<p>无论你使用PHP, ASP.NET, Mootools, jQuery，或他们中的多种，请考虑适时的使用架构。</p>
<p>例如:</p>
<ul>
<li>如果我要在网站上运行一个简单的静态页面，仅需要一个小的Javascript来实现翻转效果，那么使用jQuery的话就不太合适了。</li>
<li>如果我的静态网站的大多数特性被放在一个XML文件中，我就不需要使用架构。否则，我将会网站额外的带宽付出许多费用。</li>
</ul>
<p>但是，如果我正在建设一个负责的网站，需要一个完整的CMS系统和复杂的数据访问，那么我将会使用一些我常用的架构。</p>
<p>请记住：架构仅仅是在需要的时候才会为你服务，否则请慎用。</p>
<h3 style="font-size: 1.17em;">YSlow</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/ySlowWebsite.png" alt="ySlow" /></div>
<p>YSlow是一款非常棒的工具可以帮助你检查网站的有效性。</p>
<p>这里有一个很好的 <a href="http://developer.yahoo.net/blog/archives/2007/08/yslow-podcast-screencast.html">YSlow视频教程</a> 来讲述该款工具的实用性。我强烈推荐你有机会看一看。</p>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/yslowDebug.png" alt="ySlow" /></div>
<h3 style="font-size: 1.17em;">学会使用键盘快捷键</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/keyboard.jpg" alt="template" /></div>
<p>大多数有经验的设计师/开发人员都会同意我的观点，如果我要实现网站或者设计的一个变化我都要去工具栏里面寻找相应的菜单，那会浪费我很多时间。我已经使用快捷键很长时间了，以至于我根本不知道这些命令的正确菜单位置。我就知道&#8221;Shift + X&#8221; 可以打开我需要的面板。</p>
<p>我建议你可以在Google中搜索 &#8220;X 快捷键&#8221;（X代表软件的名字，比如Photoshop）。打印这些表单放在你垂手可得的地方。在接下来的几个星期中，试着尽可能用鼠标进行操作，渐渐地你就会养成习惯了。</p>
<h3 style="font-size: 1.17em;">建立一个 &#8220;New Website&#8221;模板</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/template.png" alt="template" /></div>
<p>让我们来看看如何建立一个网站模板。并非所有的网站都需要大型而复杂的应用。有时候，我们仅仅需要一个可以展示我们简历的网站。这时，我们为何不建立一个简单的“模板”来包含你需要的任何东西呢？</p>
<p>在我的模板文件夹里面，我建立了名为&#8221;JS&#8221;和&#8221;CSS&#8221;的二级文件夹。</p>
<ul>
<li>前者包含了我的<a href="http://nettuts.com/videos/screencasts/5-easy-ways-to-tackle-ie6s-transparency-issues/">&#8220;DD_belatedPNG.js&#8221;</a> 文件 (支持IE6 PNG背景透明)。</li>
<li>后者包含了一个空白的&#8221;default.css&#8221; 文件以及我自己的自定义reset文件。</li>
</ul>
<p>除此之外，我还有一个 &#8220;index.html(php)&#8221; 文件包含了一些我常用的代码片段。这些并没有什么特别之处，不过会节约我不少时间。</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="html4strict"><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"><!--mce:2--></script></pre>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="html4strict"><script type="text/javascript"><!--mce:3--></script></pre>
<table style="cursor: default; border: 1px dashed #bbbbbb;" border="0">
<tbody></tbody>
</table>
<p>正如你所看到的，我引用了我自己的CSS 和Javascript文件,链接了Google上的 jQuery文件，创建了document.ready() jQuery函数，并且打开了一个标准的&#8221;container&#8221; div。</p>
<p>这看上去非常简单，但却节省了不少时间。</p>
<h3 style="font-size: 1.17em;">内联Vs.外联</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/inline.jpg" alt="inline and external" /></div>
<p>总的来说，你的所有CSS和Javascript文件应该从页面上移走放入其各自的外部文件中。</p>
<h4 style="font-size: 1em;">为什么这么做?</h4>
<ul>
<li>清理代码</li>
<li>简报和内容分开很重要</li>
<li>使用外部文件，数据会被缓存以备后用。这将降低HTML文件大小而不会导致多余的HTTP请求。</li>
</ul>
<p>如果你仅有几句简单的样式结构，还是可以有例外的。把他们放在HTML页面内或许还是有益的，但仅限此种情况而已。</p>
<h3 style="font-size: 1.17em;">使用PHP判定Javascript调本是否被调用</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/requestedWith.png" alt="inline and external" /></div>
<p>AJAX几乎应用到了现在所有的领域，多数是因为他的用户友好性，这些都要归功于Javascript 库。在有些情况下，你需要考虑是否需要使用Javascrip来调用你的脚本。这需要几天的时间来完成这项任务。</p>
<p>其中一个方法就是当发送POST命令的时候使用Javascript附加上一对独特的键值。然后你可以使用PHP来决定某个特殊的值是否存在。如果存在的话，我们就会知道Javascript被调用了。</p>
<p>一个最好的构建方式就是使用PHP的特性&#8221;HTTP_X_REQUESTED_WITH&#8221;。</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="php">if isset($_SERVER['HTTP_X_REQUESTED_WITH']) {</pre>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="php">// write some code and rest assured that the Javascript is enabled.</pre>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="php">} else {</pre>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="php">// Do something different to compensate for users that have JS turned off.</pre>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace;" lang="php">}</pre>
<table style="cursor: default; border: 1px dashed #bbbbbb;" border="0">
<tbody></tbody>
</table>
<h3 style="font-size: 1.17em;">连接到Google的CDN</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/linkToGoogle.png" alt="link to google" /></div>
<p>不久前，Google主机开始存放一些流行的脚本库如jQuery等。如果你正在使用类似的库，我强烈建议你将它们链接到Google的CDN，而不是使用你自己的脚本。</p>
<p><a style="text-decoration: none;" href="http://code.google.com/apis/ajaxlibs/">AJAX Libraries API</a></p>
<h3 style="font-size: 1.17em;">使用Firefox扩展</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/firefoxExtensions.png" alt="embrace firefox extensions" /></div>
<p>我是Google Chrome的忠实用户。他打开的速度非常快，并且运行Javascript的速度也比其他浏览器快很多，至少到目前为止是这样的。但是，你会发现我并不会很快放弃使用Firefox的。它的一系列非常有用的浏览器插件是令人惊叹的。下面就是我最常用的一些：</p>
<ul>
<li><a href="https://addons.mozilla.org/firefox/addon/60"><strong>Web Developer Toolbar</strong></a></li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/3247"><strong>S3 Organizer</strong></a></li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/1347"><strong>Clippings</strong></a></li>
<li><a href="https://addons.mozilla.org/firefox/addon/1843"><strong>Firebug</strong></a></li>
<li><a href="https://addons.mozilla.org/firefox/addon/1419"><strong>IE Tab</strong></a></li>
<li><a href="http://fireftp.mozdev.org/"><strong>FireFTP</strong></a></li>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/201"><strong>DownThemAll</strong></a></li>
<li><a href="https://addons.mozilla.org/firefox/addon/5369"><strong>YSlow</strong></a></li>
</ul>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/firefoxEnxtensionZOOMED.png" alt="embrace firefox extensions" /></div>
<h3 style="font-size: 1.17em;">如果有用的话，可以使用IDE</h3>
<div><img style="border: 0px initial initial;" src="http://nettuts.s3.amazonaws.com/180_efficientcode/ide.png" alt="use an ide" /></div>
<p>现在痛恨微软似乎变得非常流行，攻击那些在开发的时候使用IDE的人似乎非常时髦。事实上，这样看来比较愚蠢。</p>
<p>在很多情况，使用高级的IDE应该还是首选，特别是当你在使用OOP语言工作的时候。现在，如果你仅仅是创建一个小巧的HTML模板，<a href="http://notepad-plus.sourceforge.net/uk/site.htm">Notepad++</a>和<a href="http://www.panic.com/coda/">Coda</a>这样的程序已经非常棒了。事实上，在这种情况下我还是建议使用这样的工具的，毕竟多余的功能对你来说没有任何用处。但是，当你开发一些高级程序的时候，还是充分利用IDE的优势吧。</p>
<p>[<a href="http://net.tutsplus.com/articles/general/15-tips-to-speed-up-your-website-and-optimize-your-code/">原文链接</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://www.4ebstudio.com/15-tips-to-speed-up-your-website-and-optimize-your-code.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>学习10款常用的jQuery特效</title>
		<link>http://www.4ebstudio.com/jquery-tutorials-for-designers.html</link>
		<comments>http://www.4ebstudio.com/jquery-tutorials-for-designers.html#comments</comments>
		<pubDate>Wed, 12 Nov 2008 06:28:54 +0000</pubDate>
		<dc:creator>4EB Studio</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[天兔贴士]]></category>
		<category><![CDATA[网页设计]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[网页特效]]></category>

		<guid isPermaLink="false">http://4ebstudio.com/?p=88</guid>
		<description><![CDATA[最近开始学习jQuery，这款大受好评的轻量级javascript库。买了本《jQuery基础教程》(Learning jQuery)，刚开始看。很喜欢看国外的这些书籍，译本也好，原文也好，感觉讲的很透彻，基本都是以最先进的互联网标准作为依托讲解的，帮助读者建立全新的web design观念。这些也是国内类似的书籍出版商和作者应该学习的。多看看这些文章，绝对会使你的设计水平和国际接轨。
今天在Web Designer Wall上看到了这样一篇关于jQuery的文章，感觉非常实用，拿来编译一下和大家分享。当然你也可以直接查看原文。
该篇文章通过10个最常用的jQuery效果向设计师和初学者讲述了如何使用jQuery创建Javascript特效。
jQuery如何运行?


首先你需要下载jQuery库并将其插入到你的html页面中(最好是放在 &#60;head&#62;标签内)。然后你需要调用脚本运行函数。下面的图例像你详细解释了jQuery是如何运行的。


如何获取元素?
编写jQuery函数相对来说比较简单。你需要掌握的关键点就是如何准确的使用你所需效果的元素。

$("#header") = 获取id为&#8221;header&#8221;的元素
$("h3") = 获取所有标签为&#60;h3&#62;的元素
$("div#content .photo") = 获取所有&#60;div id=&#8221;content&#8221;&#62;内类为&#8221;photo&#8221;的元素
$("ul li") = 获取所有&#60;ul&#62;内的&#60;li&#62;元素
$("ul li:first") = 获取&#60;ul&#62;内的第一个&#60;li&#62;元素

1.简单的滑动版
让我们从最简单的滑动版开始。你可能已经见过很多类似的效果了，当你点击一个链接的时候，一个滑动版便向上(下)展开 (view demo)

当类名为&#8221;btn-slide&#8221;的元素被点击的时候，它将向上(或下)切换(slideToggle) &#60;div id=&#8221;panel&#8221;&#62;元素，然后切换一个CSS类&#8221;active&#8221;到&#60;a&#62;元素。通过使用css样式，类名为.active的元素将会切换箭头图片的背景位置。
$(document).ready(function(){$(".btn-slide").click(function(){$("#panel").slideToggle("slow");$(this).toggleClass("active");});

});
2.简单的消失效果
该示例向你讲述如何设计点击图片按钮后该区域内容消失的效果 (view demo)

当图片元素&#60;img&#62; 被点击的时候，它会查找其父元素 &#60;div&#62;，并且缓慢的隐藏其透明度。
$(document).ready(function(){$(".pane .delete").click(function(){$(this).parents(".pane").animate({ opacity: "hide" }, "slow");});

});
3Chain-able过渡效果
现在让我们来看看jQuery强大的Chain-able效果。仅需几行代码就可以设计出一个按比例变化大小并且渐变消失的飞行的盒子。(view demo)

第1行和第2行: 创建&#60;a&#62;元素被点击时的函数
第3行: 赋予&#60;div id=&#8221;box&#8221;&#62;元素的.animate函数不透明度值为0.1, 左边可到达的距离为400px, 速度为1200毫秒
第4行: 赋予.animate函数不透明度值为0.4，顶部距离160px, 高20, 宽20, 速度为&#8221;slow&#8221;
第5行: 接下来赋予.animate函数不透明度值为1, 左边距离为0, 高100, 宽100, 速度为&#8221;slow&#8221;
第6行: 设置.animate函数的top值为0,速度为&#8221;fast&#8221;
第7行: 调用slideUp函数 (默认速度值为&#8221;normal&#8221;)
第8行: 调用slideDown, 速度值为&#8221;slow&#8221;
$(document).ready(function(){$(".run").click(function(){

$("#box").animate({opacity: "0.1", left: "+=400"}, 1200).animate({opacity: "0.4", top: "+=160", [...]]]></description>
			<content:encoded><![CDATA[<p>最近开始学习jQuery，这款大受好评的轻量级javascript库。买了本《jQuery基础教程》(Learning jQuery)，刚开始看。很喜欢看国外的这些书籍，译本也好，原文也好，感觉讲的很透彻，基本都是以最先进的互联网标准作为依托讲解的，帮助读者建立全新的web design观念。这些也是国内类似的书籍出版商和作者应该学习的。多看看这些文章，绝对会使你的设计水平和国际接轨。</p>
<p>今天在<a href="http://www.webdesignerwall.com/" target="_blank">Web Designer Wall</a>上看到了这样一篇关于jQuery的文章，感觉非常实用，拿来编译一下和大家分享。当然你也可以直接查看<a href="http://www.webdesignerwall.com/tutorials/jquery-tutorials-for-designers/" target="_blank">原文</a>。</p>
<p>该篇文章通过10个最常用的jQuery效果向设计师和初学者讲述了如何使用jQuery创建Javascript特效。</p>
<p><span style="font-size: 14px;"><strong>jQuery如何运行?</strong></span></p>
<p><span style="font-size: 14px;"><strong><span id="more-88"></span><br />
</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">首先你需要下载<a style="text-decoration: none;" href="http://jquery.com/">jQuery</a>库并将其插入到你的html页面中(最好是放在<code> &lt;head&gt;</code>标签内)。然后你需要调用脚本运行函数。下面的图例像你详细解释了jQuery是如何运行的。</p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/wp-content/uploads/2008/02/jquery-how-it-works.gif"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/jquery-how-it-works.gif" alt="how jquery works" width="555" height="266" /></a></p>
<p><img style="border-top-width: 1px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-top-style: dotted; border-top-color: #cccccc; display: block; width: 475px; height: 12px; margin-top: 15px; background-image: url(http://192.168.0.169/4eb/wp-includes/js/tinymce/plugins/wordpress/img/more_bug.gif); background-repeat: no-repeat; background-attachment: initial; -webkit-background-clip: initial; -webkit-background-origin: initial; background-color: #ffffff; background-position: 100% 0%;" title="更多..." src="http://192.168.0.169/4eb/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif" alt="" /></p>
<p><strong>如何获取元素?</strong></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">编写jQuery函数相对来说比较简单。你需要掌握的关键点就是如何准确的使用你所需效果的元素。</p>
<ul style="padding-top: 0.5em; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; margin: 0px;">
<li style="padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 18px; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/bullet.gif); background-repeat: no-repeat; line-height: 18px; background-position: 4px 4px; margin: 0px;"><code>$("#header")</code> = 获取id为&#8221;header&#8221;的元素</li>
<li style="padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 18px; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/bullet.gif); background-repeat: no-repeat; line-height: 18px; background-position: 4px 4px; margin: 0px;"><code>$("h3")</code> = 获取所有标签为&lt;h3&gt;的元素</li>
<li style="padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 18px; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/bullet.gif); background-repeat: no-repeat; line-height: 18px; background-position: 4px 4px; margin: 0px;"><code>$("div#content .photo")</code> = 获取所有&lt;div id=&#8221;content&#8221;&gt;内类为&#8221;photo&#8221;的元素</li>
<li style="padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 18px; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/bullet.gif); background-repeat: no-repeat; line-height: 18px; background-position: 4px 4px; margin: 0px;"><code>$("ul li")</code> = 获取所有&lt;ul&gt;内的&lt;li&gt;元素</li>
<li style="padding-top: 0px; padding-right: 0px; padding-bottom: 1em; padding-left: 18px; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/bullet.gif); background-repeat: no-repeat; line-height: 18px; background-position: 4px 4px; margin: 0px;"><code>$("ul li:first")</code> = 获取&lt;ul&gt;内的第一个&lt;li&gt;元素</li>
</ul>
<p><span style="font-size: 14px;"><strong>1.简单的滑动版</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">让我们从最简单的滑动版开始。你可能已经见过很多类似的效果了，当你点击一个链接的时候，一个滑动版便向上(下)展开 <em>(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/simple-slide-panel.html">demo</a>)</em></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/simple-slide-panel.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/sample1.gif" alt="sample" width="480" height="201" /></a></p>
<p>当类名为&#8221;btn-slide&#8221;的元素被点击的时候，它将向上(或下)切换(slideToggle) &lt;div id=&#8221;panel&#8221;&gt;元素，然后切换一个CSS类&#8221;active&#8221;到&lt;a&gt;元素。通过使用css样式，类名为.active的元素将会切换箭头图片的背景位置。</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document).ready(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".btn-slide"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #0000ff; padding: 0px; margin: 0px;">"#panel"</span>).slideToggle(<span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>);$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).toggleClass(<span style="color: #0000ff; padding: 0px; margin: 0px;">"active"</span>);});

});</code></pre>
<p><span style="font-size: 14px;"><strong>2.简单的消失效果</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">该示例向你讲述如何设计点击图片按钮后该区域内容消失的效果 <em>(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/simple-disappear.html">demo</a>)</em></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/simple-disappear.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/sample2.gif" alt="sample" /></a></p>
<p>当图片元素&lt;img&gt; 被点击的时候，它会查找其父元素 &lt;div&gt;，并且缓慢的隐藏其透明度。</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document).ready(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane .delete"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).parents(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane"</span>).animate({ opacity: <span style="color: #0000ff; padding: 0px; margin: 0px;">"hide"</span> }, <span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>);});

});</code></pre>
<p><span style="font-size: 14px;"><strong>3Chain-able过渡效果</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">现在让我们来看看jQuery强大的Chain-able效果。仅需几行代码就可以设计出一个按比例变化大小并且渐变消失的飞行的盒子。<span style="font-style: italic; font-family: Georgia; font-size: 13px;">(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/chainable-effects.html">demo</a>)</span></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/chainable-effects.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/multi-animation.gif" alt="sample" /></a></p>
<p><strong>第1行和第2行</strong>: 创建&lt;a&gt;元素被点击时的函数</p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;"><strong>第3行</strong>: 赋予&lt;div id=&#8221;box&#8221;&gt;元素的.animate函数不透明度值为0.1, 左边可到达的距离为400px, 速度为1200毫秒<br />
<strong>第4行</strong>: 赋予.animate函数不透明度值为0.4，顶部距离160px, 高20, 宽20, 速度为&#8221;slow&#8221;<br />
<strong>第5行</strong>: 接下来赋予.animate函数不透明度值为1, 左边距离为0, 高100, 宽100, 速度为&#8221;slow&#8221;<br />
<strong>第6行</strong>: 设置.animate函数的top值为0,速度为&#8221;fast&#8221;<br />
<strong>第7行</strong>: 调用slideUp函数 (默认速度值为&#8221;normal&#8221;)<br />
<strong>第8行</strong>: 调用slideDown, 速度值为&#8221;slow&#8221;<strong></strong></p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document)<span style="color: #ff00ff; font-size: 14px; padding: 0px; margin: 0px;">.ready</span>(function()<span style="color: #ff00ff; font-size: 14px; padding: 0px; margin: 0px;">{$(".run").click(function(){

$("#box").animate({opacity:<span style="color: #0000ff; padding: 0px; margin: 0px;"> "0.1", left: "+=400"</span>}</span>, 1200)<span style="color: #ff00ff; font-size: 14px; padding: 0px; margin: 0px;">.animate</span>(<span style="color: #ff00ff; font-size: 14px; padding: 0px; margin: 0px;">{opacity:<span style="color: #0000ff; padding: 0px; margin: 0px;"> "0.4", top: "+=160", height: "20", width: "20"</span>}</span>, "slow")<span style="color: #ff00ff; font-size: 14px; padding: 0px; margin: 0px;">.animate</span>(<span style="color: #ff00ff; font-size: 14px; padding: 0px; margin: 0px;">{opacity:<span style="color: #0000ff; padding: 0px; margin: 0px;"> "1", left: "0", height: "100", width: "100"</span>}</span>, "slow")<span style="color: #ff00ff; font-size: 14px; padding: 0px; margin: 0px;">.animate</span>(<span style="color: #ff00ff; font-size: 14px; padding: 0px; margin: 0px;">{<span style="color: #000099; padding: 0px; margin: 0px;">top</span>:<span style="color: #0000ff; padding: 0px; margin: 0px;"> "0"</span>}</span>, "fast")<span style="color: #ff00ff; font-size: 14px; padding: 0px; margin: 0px;">.slideUp</span>()<span style="color: #ff00ff; font-size: 14px; padding: 0px; margin: 0px;">.slideDown</span>("slow")return false;

});

});</code></pre>
<p><span style="font-size: 14px;"><strong>4a.折叠效果1</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">下面是一个折叠效果 <em>(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/accordion1.html">demo</a>)</em></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/accordion1.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/sample3.gif" alt="sample" /></a></p>
<p>第1行：为&lt;div&gt;内的第一个&lt;H3&gt;元素添加名为&#8221;active&#8221;的类，并应用css样式(&#8220;active&#8221;类将转换箭头图标的背景位置)。<br />
第2行：隐藏&lt;div&gt;内的非第一行的所有&lt;p&gt;元素。</p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">当&lt;h3&gt;元素被点击的时候，它将滑动并切换(slideToggle)下一个&lt;p&gt;元素并且向上滑动(slideUp)它的子元素,然后切换类名为&#8221;active&#8221;的元素。</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document).ready(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".accordion h3:first"</span>).addClass(<span style="color: #0000ff; padding: 0px; margin: 0px;">"active"</span>);$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".accordion p:not(:first)"</span>).hide();

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".accordion h3"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){

$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).next(<span style="color: #0000ff; padding: 0px; margin: 0px;">"p"</span>).slideToggle(<span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>).siblings(<span style="color: #0000ff; padding: 0px; margin: 0px;">"p:visible"</span>).slideUp(<span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>);$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).toggleClass(<span style="color: #0000ff; padding: 0px; margin: 0px;">"active"</span>);$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).siblings(<span style="color: #0000ff; padding: 0px; margin: 0px;">"h3"</span>).removeClass(<span style="color: #0000ff; padding: 0px; margin: 0px;">"active"</span>);

});

});</code></pre>
<p><span style="font-size: 14px;"><strong>4b.折叠效果2</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">该示例和上面的很类似，不过可以让你自定义默认展开的面板。 <em>(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/accordion2.html">demo</a>)</em></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">In the CSS stylesheet,将<code> .accordion p</code>设置为<code> display:none</code>. 现在，假设你要将第三个面板设置为默认打开的面板。你可以这样写<code> $(".accordion2 p").eq(2).show();</code> (eq = equal)。注意起始值为0。</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document).ready(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".accordion2 h3"</span>).eq(<span style="padding: 0px; margin: 0px;">2</span>).addClass(<span style="color: #0000ff; padding: 0px; margin: 0px;">"active"</span>);$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".accordion2 p"</span>).eq(<span style="padding: 0px; margin: 0px;">2</span>).show();

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".accordion2 h3"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).next(<span style="color: #0000ff; padding: 0px; margin: 0px;">"p"</span>).slideToggle(<span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>).siblings(<span style="color: #0000ff; padding: 0px; margin: 0px;">"p:visible"</span>).slideUp(<span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>);$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).toggleClass(<span style="color: #0000ff; padding: 0px; margin: 0px;">"active"</span>);$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).siblings(<span style="color: #0000ff; padding: 0px; margin: 0px;">"h3"</span>).removeClass(<span style="color: #0000ff; padding: 0px; margin: 0px;">"active"</span>);});

});</code></pre>
<p><span style="font-size: 14px;"><strong>5a.动态悬停效果1</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">该示例将会创建一个非常漂亮的渐入渐出的动画悬停效果 <em>(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/animated-hover1.html">demo</a>)</em></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/animated-hover1.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/sample4.gif" alt="sample" /></a></p>
<p>当鼠标悬停在菜单上的时候，将会查找下一个&lt;em&gt;元素，并创建animate函数，设置其不透明度和顶部位置。</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document).ready(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".menu a"</span>).hover(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>() {$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).next(<span style="color: #0000ff; padding: 0px; margin: 0px;">"em"</span>).animate({opacity: <span style="color: #0000ff; padding: 0px; margin: 0px;">"show"</span>, top: <span style="color: #0000ff; padding: 0px; margin: 0px;">"-75"</span>}, <span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>);}, <span style="color: #000099; padding: 0px; margin: 0px;">function</span>() {$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).next(<span style="color: #0000ff; padding: 0px; margin: 0px;">"em"</span>).animate({opacity: <span style="color: #0000ff; padding: 0px; margin: 0px;">"hide"</span>, top: <span style="color: #0000ff; padding: 0px; margin: 0px;">"-85"</span>}, <span style="color: #0000ff; padding: 0px; margin: 0px;">"fast"</span>);});

});</code></pre>
<p><span style="font-size: 14px;"><strong>5b.动态悬停效果2</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">该示例为菜单链接添加<code> title</code>属性，并将它放在一个变量里面，然后附加到&lt;em&gt;标签上。 <em>(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/animated-hover2.html">demo</a>)</em></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/animated-hover2.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/sample4b.gif" alt="sample" /></a></p>
<p>第一行附加了一个空的<code> &lt;em&gt;</code> 标签到菜单的 <code>&lt;a&gt;</code> 元素上。</p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">当鼠标悬停在链接上时，获取<code> title</code> 属性，将其存放在&#8221;hoverText&#8221;变量中，然后将带有<span style="color: #000099; white-space: nowrap; font-family: 'Courier New'; font-size: 14px;">&lt;em&gt;<span style="color: #000000; white-space: normal; font-family: SimSun; font-size: 12px;">标记的文本内容赋予变量hoverText的值。</span></span></p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document).ready(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".menu2 a"</span>).append(<span style="color: #0000ff; padding: 0px; margin: 0px;">"&lt;em&gt;&lt;/em&gt;"</span>);

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".menu2 a"</span>).hover(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>() {$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).find(<span style="color: #0000ff; padding: 0px; margin: 0px;">"em"</span>).animate({opacity: <span style="color: #0000ff; padding: 0px; margin: 0px;">"show"</span>, top: <span style="color: #0000ff; padding: 0px; margin: 0px;">"-75"</span>}, <span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>);<span style="color: #000099; padding: 0px; margin: 0px;">var</span> hoverText = $(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).attr(<span style="color: #0000ff; padding: 0px; margin: 0px;">"title"</span>);$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).find(<span style="color: #0000ff; padding: 0px; margin: 0px;">"em"</span>).text(hoverText);}, <span style="color: #000099; padding: 0px; margin: 0px;">function</span>() {$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).find(<span style="color: #0000ff; padding: 0px; margin: 0px;">"em"</span>).animate({opacity: <span style="color: #0000ff; padding: 0px; margin: 0px;">"hide"</span>, top: <span style="color: #0000ff; padding: 0px; margin: 0px;">"-85"</span>}, <span style="color: #0000ff; padding: 0px; margin: 0px;">"fast"</span>);});

});</code></pre>
<p><span style="font-size: 14px;"><strong>6.整个块元素点击效果</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">该示例展示了如何创建整个块元素点击效果变换的方式。<em>(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/block-clickable.html">demo</a>)</em></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/block-clickable.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/sample5.gif" alt="sample" /></a></p>
<p>假设你有一个类名为&#8221;pane-list&#8221;的<span style="color: #000099; white-space: nowrap; font-family: 'Courier New'; font-size: 14px;">&lt;ul&gt;<span style="color: #000000; white-space: normal; font-family: SimSun; font-size: 12px;">a，并让其子元素<code> &lt;li&gt;</code> 的整个模块可以点击。你可以为&#8221;.pane-list li&#8221;创建一个点击函数，当其被点击的时候，函数会查找<span style="color: #000099; white-space: nowrap; font-family: 'Courier New'; font-size: 14px;">&lt;a&gt;<span style="color: #000000; white-space: normal; font-family: SimSun; font-size: 12px;">元素，并重新定向到<span style="color: #000099; white-space: nowrap; font-family: 'Courier New'; font-size: 14px;">href<span style="color: #000000; white-space: normal; font-family: SimSun; font-size: 12px;">属性值的地址。</span></span></span></span></span></span></p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document).ready(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane-list li"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){window.location=$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).find(<span style="color: #0000ff; padding: 0px; margin: 0px;">"a"</span>).attr(<span style="color: #0000ff; padding: 0px; margin: 0px;">"href"</span>); <span style="color: #000099; padding: 0px; margin: 0px;">return</span> <span style="padding: 0px; margin: 0px;">false</span>;});

});</code></pre>
<p><span style="font-size: 14px;"><strong>7.折叠面板</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">让我们结合前面的一些技术来创建一个可折叠的面板。<em>(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/collapsible-panels.html">demo</a>)</em></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/collapsible-panels.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/sample6.gif" alt="sample" /></a></p>
<p><strong>第1段</strong>: 隐藏第一个面板后的所有类名为&#8221;message_body&#8221;的块</p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;"><strong>第2段</strong>: 隐藏第5个以后的所有&lt;li&gt;元素<br />
<strong>第3段：</strong>当&lt;p&gt;被点击的时候，滑动并且换(slideToggle)到下一个&lt;div&gt;块。<br />
<strong>第4段</strong>: 当&lt;a&gt;按钮被点击的时候，向上滑动所有的&lt;div&gt;块。<br />
<strong>第5段</strong>: 当&lt;a&gt;被点击的时候，隐藏该元素，显示&lt;a&gt;元素,并且向下移动(slideDown)所有第5个以后的&lt;li&gt;元素<br />
<strong>第6段</strong>: 当&lt;a&gt;被点击的时候, 隐藏该元素，显示&lt;a&gt;元素,并且向上移动(slideUp)所有第5个以后的&lt;li&gt;元素</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document).ready(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){<span style="color: #888888; padding: 0px; margin: 0px;">//hide message_body after the first one</span>$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".message_list .message_body:gt(0)"</span>).hide();

<span style="color: #888888; padding: 0px; margin: 0px;">//hide message li after the 5th</span>$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".message_list li:gt(4)"</span>).hide();

<span style="color: #888888; padding: 0px; margin: 0px;">//toggle message_body</span>$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".message_head"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).next(<span style="color: #0000ff; padding: 0px; margin: 0px;">".message_body"</span>).slideToggle(<span style="padding: 0px; margin: 0px;">500</span>)<span style="color: #000099; padding: 0px; margin: 0px;">return</span> <span style="padding: 0px; margin: 0px;">false</span>;});

<span style="color: #888888; padding: 0px; margin: 0px;">//collapse all messages</span>$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".collpase_all_message"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".message_body"</span>).slideUp(<span style="padding: 0px; margin: 0px;">500</span>)<span style="color: #000099; padding: 0px; margin: 0px;">return</span> <span style="padding: 0px; margin: 0px;">false</span>;});

<span style="color: #888888; padding: 0px; margin: 0px;">//show all messages</span>$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".show_all_message"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).hide()$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".show_recent_only"</span>).show()$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".message_list li:gt(4)"</span>).slideDown()<span style="color: #000099; padding: 0px; margin: 0px;">return</span> <span style="padding: 0px; margin: 0px;">false</span>;});

<span style="color: #888888; padding: 0px; margin: 0px;">//show recent messages only</span>$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".show_recent_only"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).hide()$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".show_all_message"</span>).show()$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".message_list li:gt(4)"</span>).slideUp()<span style="color: #000099; padding: 0px; margin: 0px;">return</span> <span style="padding: 0px; margin: 0px;">false</span>;});

});</code></pre>
<p><span style="font-size: 14px;"><strong>8.模仿WordPress的评论后台</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">我相信大多数人都见过WordPress的Ajax评论管理后台。现在让我们用jQuery来模仿一个。为了制造背景颜色动态效果，你需要使用<a style="border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #cccccc; padding-top: 1px; padding-right: 0px; padding-bottom: 1px; padding-left: 0px; outline-style: none; text-decoration: none; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/link-bg.gif); background-repeat: repeat-x; color: #000000; margin: 0px;" href="http://plugins.jquery.com/project/color"><strong>Color Animations</strong></a> 插件。<span style="font-style: italic; font-family: Georgia; font-size: 13px;">(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/wordpress-comments.html">demo</a>)</span></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/wordpress-comments.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/sample7.gif" alt="sample" /></a></p>
<p><strong>第1段</strong>: 添加&#8221;alt&#8221;类到所有偶数行&lt;div&gt;块，(隔行添加灰色背景)</p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;"><strong>第2段</strong>: 当&lt;a&gt;被点击的时候, 出现提示信息，并变换&lt;div&gt;的背景颜色和不透明度<strong><br />
第3段</strong>: 当&lt;a&gt; 被点击的时候, 先将&lt;div&gt;的背景颜色变为黄色，然后变为白色，并添加&#8221;spam&#8221;类<br />
<strong>第4段</strong>: 当&lt;a&gt;被点击的时候，先将&lt;div&gt;背景颜色变为绿色，然后变为白色，并移走&#8221;spam&#8221;类<strong><br />
第5段</strong>: 当&lt;a&gt; is clicked, animate the backgroundColor to red and opacity =&#8221;hide&#8221;</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;"><span style="color: #888888; padding: 0px; margin: 0px;">//don't forget to include the Color Animations plugin</span><span style="color: #888888; padding: 0px; margin: 0px;">//&lt;script type="text/javascript" src="jquery.color.js"&gt;&lt;/script&gt;</span>$(document).ready(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane:even"</span>).addClass(<span style="color: #0000ff; padding: 0px; margin: 0px;">"alt"</span>);

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane .btn-delete"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){alert(<span style="color: #0000ff; padding: 0px; margin: 0px;">"This comment will be deleted!"</span>);

$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).parents(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane"</span>).animate({ backgroundColor: <span style="color: #0000ff; padding: 0px; margin: 0px;">"#fbc7c7"</span> }, <span style="color: #0000ff; padding: 0px; margin: 0px;">"fast"</span>).animate({ opacity: <span style="color: #0000ff; padding: 0px; margin: 0px;">"hide"</span> }, <span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>)<span style="color: #000099; padding: 0px; margin: 0px;">return</span> <span style="padding: 0px; margin: 0px;">false</span>;});

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane .btn-unapprove"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).parents(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane"</span>).animate({ backgroundColor: <span style="color: #0000ff; padding: 0px; margin: 0px;">"#fff568"</span> }, <span style="color: #0000ff; padding: 0px; margin: 0px;">"fast"</span>).animate({ backgroundColor: <span style="color: #0000ff; padding: 0px; margin: 0px;">"#ffffff"</span> }, <span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>).addClass(<span style="color: #0000ff; padding: 0px; margin: 0px;">"spam"</span>)<span style="color: #000099; padding: 0px; margin: 0px;">return</span> <span style="padding: 0px; margin: 0px;">false</span>;});

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane .btn-approve"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).parents(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane"</span>).animate({ backgroundColor: <span style="color: #0000ff; padding: 0px; margin: 0px;">"#dafda5"</span> }, <span style="color: #0000ff; padding: 0px; margin: 0px;">"fast"</span>).animate({ backgroundColor: <span style="color: #0000ff; padding: 0px; margin: 0px;">"#ffffff"</span> }, <span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>).removeClass(<span style="color: #0000ff; padding: 0px; margin: 0px;">"spam"</span>)<span style="color: #000099; padding: 0px; margin: 0px;">return</span> <span style="padding: 0px; margin: 0px;">false</span>;});

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane .btn-spam"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).parents(<span style="color: #0000ff; padding: 0px; margin: 0px;">".pane"</span>).animate({ backgroundColor: <span style="color: #0000ff; padding: 0px; margin: 0px;">"#fbc7c7"</span> }, <span style="color: #0000ff; padding: 0px; margin: 0px;">"fast"</span>).animate({ opacity: <span style="color: #0000ff; padding: 0px; margin: 0px;">"hide"</span> }, <span style="color: #0000ff; padding: 0px; margin: 0px;">"slow"</span>)<span style="color: #000099; padding: 0px; margin: 0px;">return</span> <span style="padding: 0px; margin: 0px;">false</span>;});

});</code></pre>
<p><span style="font-size: 14px;"><strong>9.图像替换</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">假设你有一套个人图片集，需要在一个页面上显示多幅图像而无须切换页面，你可以加载JPG图像到目标元素上。 <em>(view<a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/img-replacement.html">demo</a>)</em></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/img-replacement.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/sample8.jpg" alt="sample" /></a></p>
<p>首先在H2元素上添加一个空的&lt;em&gt;。</p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">当&lt;p&gt;内的链接被点击的时候：</p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">- 将<code> href</code> 属性存放在变量 &#8220;largePath&#8221;中<br />
- 将<code> title</code> 属性存放在变量 &#8220;largeAlt&#8221;中<br />
- 替换&lt;img id=&#8221;largeImg&#8221;&gt;的<code> scr</code>属性为变量&#8221;largePath&#8221;，并替换<code> alt</code>属性为变量 &#8220;largeAlt&#8221;<br />
- 将<code> em</code>内容 (在<code> h2</code>标签内的)赋予变量largeAlt</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 14px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 19px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document).ready(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){$(<span style="color: #0000ff; padding: 0px; margin: 0px;">"h2"</span>).append(<span style="color: #0000ff; padding: 0px; margin: 0px;">'&lt;em&gt;&lt;/em&gt;'</span>)

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">".thumbs a"</span>).click(<span style="color: #000099; padding: 0px; margin: 0px;">function</span>(){

<span style="color: #000099; padding: 0px; margin: 0px;">var</span> largePath = $(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).attr(<span style="color: #0000ff; padding: 0px; margin: 0px;">"href"</span>);<span style="color: #000099; padding: 0px; margin: 0px;">var</span> largeAlt = $(<span style="color: #000099; padding: 0px; margin: 0px;">this</span>).attr(<span style="color: #0000ff; padding: 0px; margin: 0px;">"title"</span>);

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">"#largeImg"</span>).attr({ src: largePath, alt: largeAlt });

$(<span style="color: #0000ff; padding: 0px; margin: 0px;">"h2 em"</span>).html(<span style="color: #0000ff; padding: 0px; margin: 0px;">" ("</span> + largeAlt + <span style="color: #0000ff; padding: 0px; margin: 0px;">")"</span>); <span style="color: #000099; padding: 0px; margin: 0px;">return</span> <span style="padding: 0px; margin: 0px;">false</span>;});

});</code></pre>
<p><span style="font-size: 14px;"><strong>10.定义不同的链接样式</strong></span></p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">在大多数现代浏览器中，定义link选择器是非常容易的。例如，定义一个链接到.pdf文件，你可以简单的使用以下css规则：<code> a[href $='.pdf'] { ... }</code>。不幸的是，IE6并不支持这个语法（这是为什么<a style="text-decoration: none;" href="http://www.webdesignerwall.com/general/trash-all-ie-hacks/">我们恨IE</a>!的另一个原因）。为了实现这样的效果，你可以使用jQuery<span style="font-style: italic; font-family: Georgia; font-size: 13px;">(view <a style="text-decoration: none;" href="http://www.webdesignerwall.com/demo/jquery/link-types.html">demo</a>)</span></p>
<p style="margin-top: 4px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px;"><a href="http://www.webdesignerwall.com/demo/jquery/link-types.html"><img style="padding: 10px; border: 1px solid #cccccc;" src="http://www.webdesignerwall.com/wp-content/uploads/2008/02/sample9.gif" alt="sample" /></a></p>
<p>前三行应该很容易理解，就是根据<code> href</code>属性为<code> &lt;a&gt;</code>元素添加CSS类样式。</p>
<p style="padding-top: 0px; padding-right: 0px; padding-bottom: 1.1em; padding-left: 0px; margin: 0px;">第二段是来获取<code> href</code>属性中不含有&#8221;http://www.webdesignerwall.com&#8221;字样或者不是以 &#8220;#&#8221;开头的<code> &lt;a&gt;</code> 元素，然后为其添加&#8221;external&#8221;属性，并将目标浏览器开启方式设置为&#8221;_blank&#8221;。</p>
<pre style="font: normal normal normal 12px/18px Consolas, Monaco, 'Courier New', Courier, monospace; padding: 0px; margin: 0px;"><span style="color: #333333; line-height: 19px; font-family: Arial; font-size: 13px;"><code style="margin-top: 5px; margin-right: 0px; margin-bottom: 15px; margin-left: 0px; overflow-x: auto; overflow-y: auto; font-family: 'Courier New', Courier, monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 15px; display: block; clear: both; background-image: url(http://www.webdesignerwall.com/wp-content/themes/wdw/images/code-bg.gif); color: #333333; line-height: 21px; white-space: pre; width: 440px; padding: 10px; border: 1px solid #cccccc;">$(document).ready(function(){$("a[@href$=pdf]").addClass("pdf");

$("a[@href$=zip]").addClass("zip");

$("a[@href$=psd]").addClass("psd");

$("a:not([@href*=http://www.webdesignerwall.com])").not("[href^=#]").addClass("external").attr({ target: "_blank" });

});</code></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.4ebstudio.com/jquery-tutorials-for-designers.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
