<?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; JavaScript</title>
	<atom:link href="http://www.iwanna.cn/topics/ui/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.iwanna.cn</link>
	<description></description>
	<lastBuildDate>Sat, 31 Jul 2010 15:12:14 +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://www.iwanna.cn/archives/2010/07/29/4797/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/29/4797/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 14:26:22 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[程序源码]]></category>
		<category><![CDATA[Source-code]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4797</guid>
		<description><![CDATA[如何隐藏除了特定选择器下的全部对象

$(&#8216;#target div:not(#exclude)&#8217;).hide();
 //或者
 $(&#8216;#target&#8217;).children().filter(&#8216;:not(#exclude)&#8217;).hide();

filter()起到过滤的作用。
寻找带有指定字符串的元素


var foundin = $(&#8216;*:contains(&#8221; 明河&#8221;)&#8217;);

获取垂直滚动距离

alert($(document).scrollTop());

scrollTop()非常实用的一个方法。
向表格追加一行数据

$(&#8216;#myTable tr:last&#8217;).after(&#8216;&#60;tr&#62;&#8230;&#60;/tr&#62;&#8217;);

超过一个属性时的过滤

var elements = $(&#8216;#someid  input[type=sometype][value=somevalue]&#8216;).get();

让cookies在X分钟后过期

var date = new Date();
date.setTime(date.getTime() + (x * 60 * 1000));
$.cookie(&#8216;example&#8217;, &#8216;foo&#8217;, { expires: date });

选择从第一个到第X个的元素

//从第一个到第10个
$(&#8216;a&#8217;).slice(0,10);
//或者
$(&#8216;a:lt(10)&#8217;);

获取客户端的IP

$.getJSON(&#8220;http://jsonip.appspot.com?callback=?&#8221;,function(data){
 alert( &#8220;你的IP：&#8221; + data.ip);
});

这是利用了jsonip.appspot.com提供的取IP服务。
解析XML数据源

&#60;?xml version=&#8221;1.0&#8243; ?&#62;
&#60;result&#62;
 &#60;item&#62;
 &#60;id&#62;1&#60;/id&#62;
 &#60;title&#62;title1&#60;/title&#62;
 &#60;description&#62;desc1&#60;/description&#62;
 &#60;/item&#62;
 &#60;item&#62;
 &#60;id&#62;2&#60;/id&#62;
 &#60;title&#62;title2&#60;/title&#62;
 &#60;description&#62;desc2&#60;/description&#62;
 &#60;/item&#62;
 &#60;!&#8211; &#8230; &#8211;&#62;
&#60;/result&#62;


$.get(&#8216;file.xml&#8217;,{},function(data){
 $(&#8216;item&#8217;,data).each(function(){
 var $this&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp;&#38;nbsp; = $(this);
 var id [...]]]></description>
			<content:encoded><![CDATA[<h5>如何隐藏除了特定选择器下的全部对象</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(&#8216;#target div:not(#exclude)&#8217;).hide();</li>
<li> //或者</li>
<li> $(&#8216;#target&#8217;).children().filter(&#8216;:not(#exclude)&#8217;).hide();</li>
</ol>
<p>filter()起到过滤的作用。</p>
<h5>寻找带有指定字符串的元素</h5>
<p><span id="more-4797"></span></p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>var foundin = $(&#8216;*:contains(&#8221; 明河&#8221;)&#8217;);</li>
</ol>
<h5>获取垂直滚动距离</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>alert($(document).scrollTop());</li>
</ol>
<p>scrollTop()非常实用的一个方法。</p>
<h5>向表格追加一行数据</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(&#8216;#myTable tr:last&#8217;).after(&#8216;&lt;tr&gt;&#8230;&lt;/tr&gt;&#8217;);</li>
</ol>
<h5>超过一个属性时的过滤</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>var elements = $(&#8216;#someid  input[type=sometype][value=somevalue]&#8216;).get();</li>
</ol>
<h5>让cookies在X分钟后过期</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>var date = new Date();</li>
<li>date.setTime(date.getTime() + (x * 60 * 1000));</li>
<li>$.cookie(&#8216;example&#8217;, &#8216;foo&#8217;, { expires: date });</li>
</ol>
<h5>选择从第一个到第X个的元素</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>//从第一个到第10个</li>
<li>$(&#8216;a&#8217;).slice(0,10);</li>
<li>//或者</li>
<li>$(&#8216;a:lt(10)&#8217;);</li>
</ol>
<h5>获取客户端的IP</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$.getJSON(&#8220;http://jsonip.appspot.com?callback=?&#8221;,function(data){</li>
<li> alert( &#8220;你的IP：&#8221; + data.ip);</li>
<li>});</li>
</ol>
<p>这是利用了jsonip.appspot.com提供的取IP服务。</p>
<h5>解析XML数据源</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>&lt;?xml version=&#8221;1.0&#8243; ?&gt;</li>
<li>&lt;result&gt;</li>
<li> &lt;item&gt;</li>
<li> &lt;id&gt;1&lt;/id&gt;</li>
<li> &lt;title&gt;title1&lt;/title&gt;</li>
<li> &lt;description&gt;desc1&lt;/description&gt;</li>
<li> &lt;/item&gt;</li>
<li> &lt;item&gt;</li>
<li> &lt;id&gt;2&lt;/id&gt;</li>
<li> &lt;title&gt;title2&lt;/title&gt;</li>
<li> &lt;description&gt;desc2&lt;/description&gt;</li>
<li> &lt;/item&gt;</li>
<li> &lt;!&#8211; &#8230; &#8211;&gt;</li>
<li>&lt;/result&gt;</li>
</ol>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$.get(&#8216;file.xml&#8217;,{},function(data){</li>
<li> $(&#8216;item&#8217;,data).each(function(){</li>
<li> var $this&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = $(this);</li>
<li> var id &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;= $this.find(&#8216;id&#8217;).text();</li>
<li> var title &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;= $this.find(&#8216;title&#8217;).text();</li>
<li> var description = $this.find(&#8216;description&#8217;).text();</li>
<li> //do something &#8230;</li>
<li> });</li>
<li>});</li>
</ol>
<h5>获取在id中的数字</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>&lt;div id=&#8221;sites&#8221;&gt;</li>
<li> &lt;a id=&#8221;site_1&#8243; href=&#8221;http://siteA.com&#8221;&gt;siteA&lt;/a&gt;</li>
<li> &lt;a id=&#8221;site_2&#8243; href=&#8221;http://siteB.com&#8221;&gt;siteB&lt;/a&gt;</li>
<li> &lt;a id=&#8221;site_3&#8243; href=&#8221;http://siteB.com&#8221;&gt;siteC&lt;/a&gt;</li>
<li> &#8230;</li>
<li>&lt;/div&gt;</li>
</ol>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(&#8220;#sites a&#8221;).click(function(){</li>
<li> var $this &amp;nbsp;&amp;nbsp; &amp;nbsp;= $(this);</li>
<li> var nmb &amp;nbsp;&amp;nbsp; &amp;nbsp;= $this.attr(&#8216;id&#8217;).match(/site_(\d+)/)[1];</li>
<li> &#8230;</li>
<li>});</li>
</ol>
<h5>将类似12343778 转成 12.343.778的形式</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>var delimiter = &#8216;.&#8217;;</li>
<li>$(&#8216;#result&#8217;).html()</li>
<li> .toString()</li>
<li> .replace(new RegExp(&#8220;(^\\d{&#8220;+($this.html().toString().length%3||-1)+&#8221;})(?=\\d{3})&#8221;),&#8221;$1&#8243; + delimiter)</li>
<li> .replace(/(\d{3})(?=\d)/g,&#8221;$1&#8243; + delimiter);</li>
</ol>
<p>这个正则值得收藏，颇为经典。</p>
<h5>向firebug的控制面板发送消息</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li><a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.fn.log = function (msg) {</li>
<li> console.log(&#8220;%s: %o&#8221;, msg, this);</li>
<li> return this;</li>
<li>};</li>
<li>$(&#8216;#some_div&#8217;).find(&#8216;li.source &gt; input:checkbox&#8217;).log(&#8220;sources to uncheck&#8221;).removeAttr(&#8220;checked&#8221;);</li>
</ol>
<h5>获取图片的宽高</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>var img = $(&#8216;#imageid&#8217;);</li>
<li>var theImage = new Image();</li>
<li>theImage.src = img.attr(&#8220;src&#8221;);</li>
<li>alert(&#8220;Width:  &#8221; + theImage.width);</li>
<li>alert(&#8220;Height:  &#8221; + theImage.height);</li>
</ol>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/29/4797/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/29/4797/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/29/4797/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/29/4797/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/29/4797/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/source-code/" title="Source-code" rel="tag nofollow">Source-code</a>, <a href="http://www.iwanna.cn/topics/resource/" title="程序源码" rel="tag nofollow">程序源码</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4795/" title="实用jquery代码片段集合[上] (2010年07月29日)">实用jquery代码片段集合[上]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/03/29/2605/" title="基于jQuery的新闻图片 (2010年03月29日)">基于jQuery的新闻图片</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/20/4644/" title="jQuery源码分析-each函数 (2010年07月20日)">jQuery源码分析-each函数</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/13/4506/" title="推荐9个jquery手风琴菜单插件 (2010年07月13日)">推荐9个jquery手风琴菜单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/11/4460/" title="推荐8个独特应用的JQuery拖放插件 (2010年07月11日)">推荐8个独特应用的JQuery拖放插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/23/1864/" title="如何为您的博客图片添加水印效果？ (2009年06月23日)">如何为您的博客图片添加水印效果？</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/09/4451/" title="基本代码安全知识 (2010年07月9日)">基本代码安全知识</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/17/4583/" title="制作jquery文字提示插件 (2010年07月17日)">制作jquery文字提示插件</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/29/4797/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>实用jquery代码片段集合[上]</title>
		<link>http://www.iwanna.cn/archives/2010/07/29/4795/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/29/4795/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 14:24:51 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[程序源码]]></category>
		<category><![CDATA[Source-code]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4795</guid>
		<description><![CDATA[加载google的jquery库

&#60;script type=&#8221;text/javascript&#8221; src=&#8221;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&#8221;&#62;&#60;/script&#62;

有利于加快加载速度（已经得到验证）。
修改图片src更新图片

$(imageobj).attr(&#8217;src&#8217;, $(imageobj).attr(&#8217;src&#8217;) + &#8216;?&#8217; + Math.random() );


（这是很实用的技巧，曾经有人问明河，为什么他已经修改了图片的src，但图片没变化呢？原因在于缓存，给图片路径后加个随机数参数即可。
加载多张图片，判断加载完成状态

var totalimages  = 10;
var loadedimages = 0;
$(&#8220;&#60;img/&#62;&#8221;).load(function() {
 ++loadedimages;
 if(loadedimages == totalimages){
 //全部图片加载完成时&#8230;..
 }
 });

双击不选中文本

var clearSelection =  function () {
 if(document.selection &#38;&#38; document.selection.empty) {
 document.selection.empty();
 } else if(window.getSelection) {
 var sel = window.getSelection();
 sel.removeAllRanges();
 }
 }

 $(element).bind(&#8216;dblclick&#8217;,function(event){
 clearSelection();
 });

对一个列表进行排序

&#60;ul&#62;
 &#60;li&#62;cloud&#60;/li&#62;
 &#60;li&#62;sun&#60;/li&#62;
 &#60;li&#62;rain&#60;/li&#62;
 &#60;li&#62;snow&#60;/li&#62;
&#60;/ul


var items = [...]]]></description>
			<content:encoded><![CDATA[<h5>加载google的<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>库</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>&lt;script type=&#8221;text/<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">javascript</a>&#8221; src=&#8221;http://<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">ajax</a>.googleapis.com/<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">ajax</a>/libs/<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>/1.4.2/<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>.min.js&#8221;&gt;&lt;/script&gt;</li>
</ol>
<p>有利于加快加载速度（已经得到验证）。</p>
<h5>修改图片src更新图片</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(imageobj).attr(&#8217;src&#8217;, $(imageobj).attr(&#8217;src&#8217;) + &#8216;?&#8217; + Math.random() );</li>
</ol>
<p><span id="more-4795"></span><br />
（这是很实用的技巧，曾经有人问明河，为什么他已经修改了图片的src，但图片没变化呢？原因在于缓存，给图片路径后加个随机数参数即可。</p>
<h5>加载多张图片，判断加载完成状态</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>var totalimages  = 10;</li>
<li>var loadedimages = 0;</li>
<li>$(&#8220;&lt;img/&gt;&#8221;).load(function() {</li>
<li> ++loadedimages;</li>
<li> if(loadedimages == totalimages){</li>
<li> //全部图片加载完成时&#8230;..</li>
<li> }</li>
<li> });</li>
</ol>
<h5>双击不选中文本</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>var clearSelection =  function () {</li>
<li> if(document.selection &amp;&amp; document.selection.empty) {</li>
<li> document.selection.empty();</li>
<li> } else if(window.getSelection) {</li>
<li> var sel = window.getSelection();</li>
<li> sel.removeAllRanges();</li>
<li> }</li>
<li> }</li>
<li></li>
<li> $(element).bind(&#8216;dblclick&#8217;,function(event){</li>
<li> clearSelection();</li>
<li> });</li>
</ol>
<h5>对一个列表进行排序</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>&lt;ul&gt;</li>
<li> &lt;li&gt;cloud&lt;/li&gt;</li>
<li> &lt;li&gt;sun&lt;/li&gt;</li>
<li> &lt;li&gt;rain&lt;/li&gt;</li>
<li> &lt;li&gt;snow&lt;/li&gt;</li>
<li>&lt;/ul</li>
</ol>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>var items = $(&#8216;.to_order  li&#8217;).get();</li>
<li></li>
<li> items.sort(function(a,b){</li>
<li> var keyA = $(a).text();</li>
<li> var keyB = $(b).text();</li>
<li> if (keyA &lt; keyB) return -1;</li>
<li> if (keyA &gt; keyB) return 1;</li>
<li> return 0;</li>
<li> });</li>
<li> var ul = $(&#8216;.to_order&#8217;);</li>
<li> $.each(items, function(i, li){</li>
<li> ul.append(li);</li>
<li> });</li>
</ol>
<p>（中文无效）</p>
<h5>绑定右击事件</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(document).ready(function(){</li>
<li> $(document).bind(&#8220;contextmenu&#8221;,function(e){</li>
<li> return false;</li>
<li> });</li>
<li> });</li>
</ol>
<h5>扩展<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>的对象选择器</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$.extend($.expr[':'], {</li>
<li> //选择器名</li>
<li> moreThanAThousand : function (a){</li>
<li> return parseInt($(a).html()) &gt; 1000;</li>
<li> }</li>
<li> });</li>
<li> $(document).ready(function() {</li>
<li> $(&#8216;td:moreThanAThousand&#8217;).<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a>(&#8216;background-color&#8217;, &#8216;#ff0000&#8242;);</li>
<li> });</li>
</ol>
<h5>检查对象是否存在</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>if ($(&#8220;#elementid&#8221;).length) {</li>
<li> //&#8230;&#8230;</li>
<li> }</li>
</ol>
<h5>取消一个<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">ajax</a>请求</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>var req = $.<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">ajax</a>({</li>
<li> type:     &#8220;POST&#8221;,</li>
<li> url:     &#8220;someurl&#8221;,</li>
<li> data:     &#8220;id=1&#8243;,</li>
<li> success: function(){</li>
<li></li>
<li> }</li>
<li> });</li>
<li> //取消<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">ajax</a>请求</li>
<li> req.abort()</li>
</ol>
<h5>检查cookies是否可用</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(document).ready(function() {</li>
<li> var dt = new Date();</li>
<li> dt.setSeconds(dt.getSeconds() + 60);</li>
<li> document.cookie = &#8220;cookietest=1; expires=&#8221; + dt.toGMTString();</li>
<li> var cookiesEnabled = document.cookie.indexOf(&#8220;cookietest=&#8221;) != -1;</li>
<li> if(!cookiesEnabled){</li>
<li> //cookies不能用&#8230;&#8230;..</li>
<li> }</li>
<li> });</li>
</ol>
<h5>获取当前元素在元素集内的索引值</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(&#8220;ul &gt; li&#8221;).click(function () {</li>
<li> var index = $(this).prevAll().length;</li>
<li> });</li>
</ol>
<p>如果你用的是jquery1.4，明河推荐使用以下方法：</p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(&#8220;ul &gt; li&#8221;).click(function () {</li>
<li> var index = $(this).index();</li>
<li> });</li>
</ol>
<h5>让一个元素相对于屏幕居中</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li><a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.fn.center = function () {</li>
<li> this.<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a>(&#8220;position&#8221;,&#8221;absolute&#8221;);</li>
<li> this.<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a>(&#8220;top&#8221;, ( $(window).height() &#8211; this.height() ) / 2+$(window).scrollTop() + &#8220;px&#8221;);</li>
<li> this.<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a>(&#8220;left&#8221;, ( $(window).width() &#8211;  this.width() ) / 2+$(window).scrollLeft() + &#8220;px&#8221;);</li>
<li> return this;</li>
<li> }</li>
<li> $(element).center();</li>
</ol>
<p>这个方法非常实用，明河严重推荐收藏</p>
<h5>获取当前页面的URL</h5>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(document).ready(function() {</li>
<li> var pathname = window.location.pathname;</li>
<li> });</li>
</ol>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/29/4795/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/29/4795/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/29/4795/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/29/4795/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/29/4795/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/source-code/" title="Source-code" rel="tag nofollow">Source-code</a>, <a href="http://www.iwanna.cn/topics/resource/" title="程序源码" rel="tag nofollow">程序源码</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4797/" title="实用jquery代码片段集合[下] (2010年07月29日)">实用jquery代码片段集合[下]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/03/29/2605/" title="基于jQuery的新闻图片 (2010年03月29日)">基于jQuery的新闻图片</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/20/4644/" title="jQuery源码分析-each函数 (2010年07月20日)">jQuery源码分析-each函数</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/13/4506/" title="推荐9个jquery手风琴菜单插件 (2010年07月13日)">推荐9个jquery手风琴菜单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/11/4460/" title="推荐8个独特应用的JQuery拖放插件 (2010年07月11日)">推荐8个独特应用的JQuery拖放插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/23/1864/" title="如何为您的博客图片添加水印效果？ (2009年06月23日)">如何为您的博客图片添加水印效果？</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/09/4451/" title="基本代码安全知识 (2010年07月9日)">基本代码安全知识</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/17/4583/" title="制作jquery文字提示插件 (2010年07月17日)">制作jquery文字提示插件</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/29/4795/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一个基于JQuery 和CSS3的滑动菜单</title>
		<link>http://www.iwanna.cn/archives/2010/07/27/4767/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/27/4767/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 14:34:26 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Menu]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4767</guid>
		<description><![CDATA[
 Demo  Download
在这里我们将要创建一个独特的滑动导航菜单。这个想法是让装有菜单项的盒子（box）滑出，并且弹出一个缩略图 片。同时还要在有需要二级菜单的链接项调用一个子菜单盒子。这个子菜单要依靠在上级菜单的左边或右边的位置悬停。

这里我们要用到jQuery Easing Plugin和tibchris的一些美丽的图片。
1. HTML结构
先来写HTML结构，这里我们用一个无序的列表来放导航菜单的一级菜单，用DIV来放子菜单。
&#60;ul id="sdt_menu" class="sdt_menu"&#62;
&#60;li&#62;
		&#60;a href="#"&#62;
			&#60;img src="images/1.jpg" alt="" /&#62;

			&#60;span class="sdt_wrap"&#62;
				&#60;span class="sdt_link"&#62;Portfolio&#60;/span&#62;
				&#60;span class="sdt_descr"&#62;My work&#60;/span&#62;
			&#60;/span&#62;
		&#60;/a&#62;
&#60;div class="sdt_box"&#62;
			&#60;a href="#"&#62;Websites&#60;/a&#62;
			&#60;a href="#"&#62;Illustrations&#60;/a&#62;
			&#60;a href="#"&#62;Photography&#60;/a&#62;&#60;/div&#62;
&#60;/li&#62;

...&#60;/ul&#62;

如果没有子菜单，DIV可以被忽视。图片在开始的时候不会被显示，我们要在CSS中为它的宽和高都设为０。
让我们开看看CSS样式
2. CSS
让我们首先为无序列表设置样式。
ul.sdt_menu{
	margin:0;
	padding:0;
	list-style: none;
	font-family:"Myriad Pro", "Trebuchet MS", sans-serif;
	font-size:14px;
	width:1020px;
}
接下来，我们要去掉菜单链接中的text-decoration和outline。
ul.sdt_menu a{
	text-decoration:none;
	outline:none;
}
我们要将列表项左浮动，并且要将position设置为relative，因为我们要为它内部的元素进行绝对定位。如要我们不那样设置，绝对定位刚是相对于整个网页的。
ul.sdt_menu li{
	float:left;
	width:170px;
	height:85px;
	position:relative;
	cursor:pointer;
}
这里来设计主链接的样式，我们有两个span，标题和描述。如下面这样来为它们写样式。
ul.sdt_menu li &#38;gt; a{
	position:absolute;
	top:0px;
	left:0px;
	width:170px;
	height:85px;
	z-index:12;
	background:transparent url(../images/overlay.png) no-repeat bottom right;
	-moz-box-shadow:0px 0px 2px #000;
	-webkit-box-shadow:0px 0px 2px #000;
	box-shadow:0px 0px 2px #000;
}
注意z-index: 我们要为重要的元素定义堆叠顺序，来让它们能够停留在上面。
我们要用一个背景图片来创造一种半透明的渐变。当你用一些背景图片（像DEMO中的木纹背景）来创造一种美丽的效果，请务必用一些不同的纹理会让它看起来 棒级了。
你也可以加上阴影－改变一下值像2px 2px 6px #000 inset，同样会给你非常好看的效果。
接下来是图片的样式:
ul.sdt_menu li a img{
	border:none;
	position:absolute;
	width:0px;
	height:0px;
	bottom:0px;
	left:85px;
	z-index:100;
	-moz-box-shadow:0px [...]]]></description>
			<content:encoded><![CDATA[<h1><a href="http://images.uheed.com/iwanna/2010/07/27/slidedownbox.jpg"><img title="slidedownbox" src="http://images.uheed.com/iwanna/2010/07/27/slidedownbox.jpg" alt="" width="580" height="315" /></a><br />
<a href="http://tympanus.net/Tutorials/SlideDownBoxMenu/" target="_blank"> Demo</a> <a href="http://tympanus.net/Tutorials/SlideDownBoxMenu/SlideDownBoxMenu.zip" target="_blank"> Download</a></h1>
<p>在这里我们将要创建一个独特的滑动导航菜单。这个想法是让装有菜单项的盒子（box）滑出，并且弹出一个缩略图 片。同时还要在有需要二级菜单的链接项调用一个子菜单盒子。这个子菜单要依靠在上级菜单的左边或右边的位置悬停。<br />
<span id="more-4767"></span><br />
这里我们要用到<a href="http://gsgd.co.uk/sandbox/jquery/easing/" target="_blank">jQuery Easing Plugin</a>和<a href="http://www.flickr.com/photos/arcticpuppy/sets/72157622090180990/" target="_blank">tibchris</a>的一些美丽的图片。</p>
<h1>1. HTML结构</h1>
<p>先来写HTML结构，这里我们用一个无序的列表来放导航菜单的一级菜单，用DIV来放子菜单。</p>
<pre><a href="http://december.com/html/4/element/ul.html">&lt;ul</a> id="sdt_menu" class="sdt_menu"&gt;
<a href="http://december.com/html/4/element/li.html">&lt;li&gt;</a>
		<a href="http://december.com/html/4/element/a.html">&lt;a</a> href="#"&gt;
			<a href="http://december.com/html/4/element/img.html">&lt;img</a> src="images/1.jpg" alt="" /&gt;

			<a href="http://december.com/html/4/element/span.html">&lt;span</a> class="sdt_wrap"&gt;
				<a href="http://december.com/html/4/element/span.html">&lt;span</a> class="sdt_link"&gt;Portfolio&lt;/span&gt;
				<a href="http://december.com/html/4/element/span.html">&lt;span</a> class="sdt_descr"&gt;My work&lt;/span&gt;
			&lt;/span&gt;
		&lt;/a&gt;
<a href="http://december.com/html/4/element/div.html">&lt;div</a> class="sdt_box"&gt;
			<a href="http://december.com/html/4/element/a.html">&lt;a</a> href="#"&gt;Websites&lt;/a&gt;
			<a href="http://december.com/html/4/element/a.html">&lt;a</a> href="#"&gt;Illustrations&lt;/a&gt;
			<a href="http://december.com/html/4/element/a.html">&lt;a</a> href="#"&gt;Photography&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;

...&lt;/ul&gt;
</pre>
<p>如果没有子菜单，DIV可以被忽视。图片在开始的时候不会被显示，我们要在<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">CSS</a>中为它的宽和高都设为０。</p>
<p>让我们开看看<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">CSS</a>样式</p>
<h1>2. <a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">CSS</a></h1>
<p>让我们首先为无序列表设置样式。</p>
<pre>ul.sdt_menu{
	margin:0;
	padding:0;
	list-style: none;
	font-family:"Myriad Pro", "Trebuchet MS", sans-serif;
	font-size:14px;
	width:1020px;
}</pre>
<p>接下来，我们要去掉菜单链接中的text-decoration和outline。</p>
<pre>ul.sdt_menu a{
	text-decoration:none;
	outline:none;
}</pre>
<p>我们要将列表项左浮动，并且要将position设置为relative，因为我们要为它内部的元素进行绝对定位。如要我们不那样设置，绝对定位刚是相对于整个网页的。</p>
<pre>ul.sdt_menu li{
	float:left;
	width:170px;
	height:85px;
	position:relative;
	cursor:pointer;
}</pre>
<p>这里来设计主链接的样式，我们有两个span，标题和描述。如下面这样来为它们写样式。</p>
<pre>ul.sdt_menu li &amp;gt; a{
	position:absolute;
	top:0px;
	left:0px;
	width:170px;
	height:85px;
	z-index:12;
	background:transparent url(../images/overlay.png) no-repeat bottom right;
	-moz-box-shadow:0px 0px 2px #000;
	-webkit-box-shadow:0px 0px 2px #000;
	box-shadow:0px 0px 2px #000;
}</pre>
<p>注意z-index: 我们要为重要的元素定义堆叠顺序，来让它们能够停留在上面。<br />
我们要用一个背景图片来创造一种半透明的渐变。当你用一些背景图片（像DEMO中的木纹背景）来创造一种美丽的效果，请务必用一些不同的纹理会让它看起来 棒级了。<br />
你也可以加上阴影－改变一下值像2px 2px 6px #000 inset，同样会给你非常好看的效果。<br />
接下来是图片的样式:</p>
<pre>ul.sdt_menu li a img{
	border:none;
	position:absolute;
	width:0px;
	height:0px;
	bottom:0px;
	left:85px;
	z-index:100;
	-moz-box-shadow:0px 0px 4px #000;
	-webkit-box-shadow:0px 0px 4px #000;
	box-shadow:0px 0px 4px #000;
}</pre>
<p>我们要加上图片由下升起的动画，这就是为什么定位它必然要用“bottom”作为参考点。我们同样加上了很棒的阴影效果。这里前两个值是0，使图片 的周围的阴影显得均匀。这甚至可以把阴影被用作一种特效，无论什么时候，你都可以创造一种边框效果。它的优点在于这些阴影不是真的存在－你不用考虑在元素 中如何来计算它的宽和高。当然现在的缺点是CSS3并不被ＩＥ支持。<br />
下面是包涵标题和描述的span的样式</p>
<pre>ul.sdt_menu li span.sdt_wrap{
	position:absolute;
	top:25px;
	left:0px;
	width:170px;
	height:60px;
	z-index:15;
}</pre>
<p>如果你有大量的文字，你则需要改变这些值。也要确保那些改变的值能匹配在<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>中设置动画的值。<br />
下一步，我们要定义一个灰色的滑动盒子的样式。我们给它的高设为0并且定位它，在动画中我们只要增加它的高度就可以了。</p>
<pre>ul.sdt_menu li span.sdt_active{
	position:absolute;
	background:#111;
	top:85px;
	width:170px;
	height:0px;
	left:0px;
	z-index:14;
	-moz-box-shadow:0px 0px 4px #000 inset;
	-webkit-box-shadow:0px 0px 4px #000 inset;
	box-shadow:0px 0px 4px #000 inset;
}</pre>
<p>接下来我们要为这些设置一些共有的样式。</p>
<pre>ul.sdt_menu li span span.sdt_link,
ul.sdt_menu li span span.sdt_descr,
ul.sdt_menu li div.sdt_box a{
	margin-left:15px;
	text-transform:uppercase;
	text-shadow:1px 1px 1px #000;
}</pre>
<p>下面是标题和描述的样式。</p>
<pre>ul.sdt_menu li span span.sdt_link{
	color:#fff;
	font-size:24px;
	float:left;
	clear:both;
}
ul.sdt_menu li span span.sdt_descr{
	color:#0B75AF;
	float:left;
	clear:both;
	width:155px;
	font-size:10px;
	letter-spacing:1px;
}</pre>
<p>子菜单盒子起初是一个隐藏在下面的灰色的盒子。我们要让它在我们在的地方动态的向右或向左滑动。像我们这个例子，当鼠标悬停在最后一个位置，我们要它动态的向左滑动，在其它的位置上我们要它向右滑动。</p>
<pre>ul.sdt_menu li div.sdt_box{
	display:block;
	position:absolute;
	width:170px;
	overflow:hidden;
	height:170px;
	top:85px;
	left:0px;
	display:none;
	background:#000;
}
ul.sdt_menu li div.sdt_box a{
	float:left;
	clear:both;
	line-height:30px;
	color:#0B75AF;
}</pre>
<p>第一个子菜单链接需要设置一个margin-top</p>
<pre>ul.sdt_menu li div.sdt_box a:first-child{
	margin-top:15px;
}
ul.sdt_menu li div.sdt_box a:hover{
	color:#fff;
}</pre>
<p>这是所有样式！让我们加上魔法！</p>
<h1>3.<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a></h1>
<p>当我们的鼠标悬停在这些列表元素上，我们要放大图片，并且显示全部，sdt_active和the sdt_wrap。如果这个元素含有子菜单(sdt_box)，将滑动到一旁。如果这个元素在菜单中是最后一个，其子菜单将滑动到左边，其余的滑向右边。</p>
<pre>$(function() {
	$('#sdt_menu &amp;gt; li').bind('mouseenter',function(){
		var $elem = $(this);
		$elem.find('img')
			 .stop(true)
			 .animate({
				'width':'170px',
				'height':'170px',
				'left':'0px'
			 },400,'easeOutBack')
			 .andSelf()
			 .find('.sdt_wrap')
			 .stop(true)
			 .animate({'top':'140px'},500,'easeOutBack')
			 .andSelf()
			 .find('.sdt_active')
			 .stop(true)
			 .animate({'height':'170px'},300,function(){
			var $sub_menu = $elem.find('.sdt_box');
			if($sub_menu.length){
				var left = '170px';
				if($elem.parent().children().length == $elem.index()+1)
					left = '-170px';
				$sub_menu.show().animate({'left':left},200);
			}
		});
	}).bind('mouseleave',function(){
		var $elem = $(this);
		var $sub_menu = $elem.find('.sdt_box');
		if($sub_menu.length)
			$sub_menu.hide().<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a>('left','0px');

		$elem.find('.sdt_active')
			 .stop(true)
			 .animate({'height':'0px'},300)
			 .andSelf().find('img')
			 .stop(true)
			 .animate({
				'width':'0px',
				'height':'0px',
				'left':'85px'},400)
			 .andSelf()
			 .find('.sdt_wrap')
			 .stop(true)
			 .animate({'top':'25px'},500);
	});
});</pre>
<p>就是这样！我们希望你能喜欢这个小菜单，它能对你有帮助。<br />
P.S. 这个在Google Chrome下看起来非常完美。</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/27/4767/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/27/4767/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/27/4767/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/27/4767/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/27/4767/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/css/" title="CSS" rel="tag nofollow">CSS</a>, <a href="http://www.iwanna.cn/tags/css/" title="CSS" rel="tag nofollow">CSS</a>, <a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/topics/ui/menu/" title="Menu" rel="tag nofollow">Menu</a>, <a href="http://www.iwanna.cn/tags/menu/" title="Menu" rel="tag nofollow">Menu</a>, <a href="http://www.iwanna.cn/tags/tutorial/" title="Tutorial" rel="tag nofollow">Tutorial</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/02/4328/" title="CSS3+JQuery实现固定头部的导航菜单 (2010年07月2日)">CSS3+JQuery实现固定头部的导航菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/04/30/915/" title="解密CSS Sprites：技巧、工具和教程 (2009年04月30日)">解密CSS Sprites：技巧、工具和教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/13/4506/" title="推荐9个jquery手风琴菜单插件 (2010年07月13日)">推荐9个jquery手风琴菜单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/17/4583/" title="制作jquery文字提示插件 (2010年07月17日)">制作jquery文字提示插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/24/1129/" title="八种布局方案改善你的设计 (2009年05月24日)">八种布局方案改善你的设计</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/09/4445/" title="jQuery + CSS3 实现图片圆角 (2010年07月9日)">jQuery + CSS3 实现图片圆角</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/30/1894/" title="40+ Web前端开发必备的备忘单[上] (2009年06月30日)">40+ Web前端开发必备的备忘单[上]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/17/4598/" title="35个 jQuery的动画教程 (2010年07月17日)">35个 jQuery的动画教程</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/27/4767/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用框架建立富联网应用</title>
		<link>http://www.iwanna.cn/archives/2010/07/27/4752/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/27/4752/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 13:41:38 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[YUI]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4752</guid>
		<description><![CDATA[JavaScript库，ICEfaces，Adobe  Flash，微软Silverlight，现在还有HTML5，全球性的网络支配地位的竞争已经进入了崭新的时代——一个富网络应用（简称RIA，中文也 有叫富互联网应用）的时代。本文目的是界定什么是RIA，解释为何网络已经开始向RIA靠拢，探索今天已经存在的不同RIA框架，对每个框架作出一些优点和缺点的概述，并讨论这些新技术在未来将是怎么样的生存态。


RIA是何物?
所谓RIA，或者说富网络网应用，就是指可以像桌面程序一样操作的网络应用。 在RIA冒出来之前，大多数的网络应用都是静态的页面构建的。

Sumo Paint 是一个基于Flash的RIA,  具有像Photoshop一样的图形编辑功能。
跟桌面应用程序不同，任何一个网页的互动往往需要重新加载一个全新的页面。而桌面应用程序，在另一方面，有很多更好的用户交互性，因为所有处理都是在用户的机器本身，所以能给以更加无缝的用户体验。
因此，软件开发商开始问自己，“我们产品应该是一个桌面应用程序还是一个Web应用程序呢？”
这一直是一个公平的问题，因为这两种类型的应用程序都具有各自优点和缺点。
桌面应用程序具有流畅的用户交互性，但软件是售出去的，会遇到发布和更新的问题。
Web应用程序，另一方面，很容易从网上获得，摆脱相关的软件发布和更新的问题，但在用户交互性体验非常差。
因此，怎么样才能两全其美呢？
RIA就是两全其美。RIA通过网络发布，有非常丰富的用户交互。得益于Ajax的出现，一个无需刷新就可以发送服务器请求的网络应用的方法，新技术出现，加入了RIA的运动。
基于这些技术出现了一些框架，帮助开发人员构建和部署富网络应用程序，如JavaScript库，ICEfaces，Adobe Flash 4（Flex 3前身），微软Silverlight，以及HTML5的。
让我们来一个个探讨RIA的框架。
网络应用的JavaScript库
JavaScript库，例如 jQuery和MooTools 是首批技术之一，可以真正的帮助部署流畅和互动的富网络应用。它们提供通过杠杆客户端脚本来处理前端接口功能的RIA框架。它们是一些基本的 Javascript文件，由一些有用的，经过跨浏览器测试功能的集成。可以使用Ajax，以及处理普通的基于用户驱动事件的交互，如显示和隐藏内容。
目前最流行的有jQuery（尤其是使用jQuery UI），MooTools，YIU（雅虎用户界面库），以及EXTJS。这些库包括RIA组件，如网格，图表和复杂的表单元素，以及处理Ajax的工具。最引人入胜的是，大部分网络开发的JavaScript库都是开源的。
如果你不想购买一个集成开发环境（IDE），但仍希望在自己的网站绚丽而专业的RIA功能，JavaScript库是一个很不错的选择。
使用JavaScript库的网站有Google，Digg，雅虎，亚马逊，微软，Twitter，以及Best Buy。
ICEfaces
ICEfaces是标准的JavaServer Faces（JSF）的框架的扩展，旨在去除方程中的JavaScript从而简化程序员的工作流程。换句话说，ICEfaces通过Java应用接口为你处理了所有的JavaScript/Ajax。通过删除这些自定义JavaScript函数的复杂引入，大大简化了创建富网络应用的任务。
如果你的团队主要成员是Java开发人员，或者如果你的网络应用程序不需要其它ICEfaces没有的复杂组件，又或者如果你的网络应用程序是事件驱动的，那么使用ICEfaces是很好的选择。如果你的网路应用是事件驱动的，请确定你已经了解ICEfaces不提供真正的“服务器推”技术的，HTML5，Flash Builder 4和Silverlight都支持的。不过，相应地ICEfaces使用长轮询的方法来模拟服务器推技术。
使用ICEfaces的网站有波音，美国航空航天局，联合太平洋公司，T-Mobile，以及美国银行。
Adobe Flash Builder 4
Flash已经出现了很长一段时间，但是用使用Flash来构建整个网络应用十分麻烦，直到Flex的引进，这是Flash的一个扩展，提供RIA网络组 件。
Adobe Flash Builder  4最令人兴奋的是它的跨平台和跨浏览器特性，允许程序在所有的操作系统和所有的浏览器上以同样的方式运行。相比于JavaScript，浏览器有不同的 JavaScript引擎管理和处理的代码，而Adobe的Flash只有一个引擎，用户通过Adobe  Flash浏览器插件来安装（通常的情况是他们有了）。
Flash Builder 4  应用之所以能如此，因为它们已经嵌入到HTML页面，这意味着浏览器本身并没有对应用程序的性能有什么影响。这意味着你如果你乐意，  你还可以在IE6上运行最复杂的网络应用程序。（这当然简单，因为Flash插件/引擎经常会更新，因此只是稍微依赖于用户插件的版本）。
这些应用通常是伴随着服务器端处理，比如一个Java后端处理，而且需要Flash Builder 4IDE做开发。
如果你的团队主要是Java开发（因为搭配Java运作良好），或者你的应用程序使用事件驱动的构架，可以选择Adobe Flash Builder  4。
使用Flash作为网络应用程序的网站有Mint.com，Flickr和Hyundai。
Silverlight
Silverlight是基本上微软版本的Adobe Flex /的Adobe Flash。现在已获得了一些吸引力，但似乎并没有达到的Adobe  Flash的普及程度。
Silverlight应用程序明显约束于.NET的后端，因为它是微软的产品。这意味着，你不得不 Silverlight /.NET 和Adobe  Flex / [一些服务器端脚本，如PHP] [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>库，ICEfaces，<a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a>  Flash，微软Silverlight，现在还有HTML5，全球性的网络支配地位的竞争已经进入了崭新的时代——一个富网络应用（简称RIA，中文也 有叫富互联网应用）的时代。</strong>本文目的是界定什么是RIA，解释为何网络已经开始向RIA靠拢，探索今天已经存在的不同RIA框架，对每个框架作出一些优点和缺点的概述，并讨论这些新技术在未来将是怎么样的生存态。<br />
<a href="http://sixrevisions.com/web-development/building-rich-internet-applications-with-frameworks/"><img src="http://images.uheed.com/iwanna/2010/07/27/13151901685270962.png" alt="Building Rich Internet Applications with Frameworks" width="550" height="200" /></a><br />
<span id="more-4752"></span><br />
<strong>RIA是何物?</strong></p>
<p>所谓RIA，或者说富网络网应用，就是指可以像桌面程序一样操作的网络应用。 在RIA冒出来之前，大多数的网络应用都是静态的页面构建的。<br />
<a href="http://www.iwanna.cn/" target="_blank"><img src="http://images.uheed.com/iwanna/2010/07/27/1315421675113898.png" alt="What's an RIA?" width="550" height="420" /></a><br />
<a href="http://www.sumopaint.com/app/">Sumo Paint</a> 是一个基于Flash的RIA,  具有像Photoshop一样的图形编辑功能。</p>
<p>跟桌面应用程序不同，任何一个网页的互动往往需要重新加载一个全新的页面。而桌面应用程序，在另一方面，有很多更好的用户交互性，因为所有处理都是在用户的机器本身，所以能给以更加无缝的用户体验。</p>
<p>因此，软件开发商开始问自己，“我们产品应该是一个桌面应用程序还是一个Web应用程序呢？”</p>
<p>这一直是一个公平的问题，因为这两种类型的应用程序都具有各自优点和缺点。</p>
<p>桌面应用程序具有流畅的用户交互性，但软件是售出去的，会遇到发布和更新的问题。</p>
<p>Web应用程序，另一方面，很容易从网上获得，摆脱相关的软件发布和更新的问题，但在用户交互性体验非常差。</p>
<p>因此，怎么样才能两全其美呢？</p>
<p>RIA就是两全其美。RIA通过网络发布，有非常丰富的用户交互。得益于<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">Ajax</a>的出现，一个无需刷新就可以发送服务器请求的网络应用的方法，新技术出现，加入了RIA的运动。</p>
<p>基于这些技术出现了一些框架，帮助开发人员构建和部署富网络应用程序，如<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>库，ICEfaces，<a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a> Flash 4（Flex 3前身），微软Silverlight，以及HTML5的。</p>
<p>让我们来一个个探讨RIA的框架。</p>
<p><strong>网络应用的<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>库</strong></p>
<p><a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>库，例如 <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>和MooTools 是首批技术之一，可以真正的帮助部署流畅和互动的富网络应用。它们提供通过杠杆客户端脚本来处理前端接口功能的RIA框架。它们是一些基本的 <a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">Javascript</a>文件，由一些有用的，经过跨浏览器测试功能的集成。可以使用<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">Ajax</a>，以及处理普通的基于用户驱动事件的交互，如显示和隐藏内容。</p>
<p>目前最流行的有<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>（尤其是使用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> UI），MooTools，YIU（雅虎用户界面库），以及EXTJS。这些库包括RIA组件，如网格，图表和复杂的表单元素，以及处理<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">Ajax</a>的工具。最引人入胜的是，大部分网络开发的<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>库都是开源的。</p>
<p>如果你不想购买一个集成开发环境（IDE），但仍希望在自己的网站绚丽而专业的RIA功能，<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>库是一个很不错的选择。</p>
<p>使用<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>库的网站有Google，Digg，雅虎，亚马逊，微软，Twitter，以及Best Buy。</p>
<p><strong>ICEfaces</strong></p>
<p>ICEfaces是标准的JavaServer Faces（JSF）的框架的扩展，旨在去除方程中的<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>从而简化程序员的工作流程。换句话说，ICEfaces通过Java应用接口为你处理了所有的<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>/<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">Ajax</a>。通过删除这些自定义<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>函数的复杂引入，大大简化了创建富网络应用的任务。</p>
<p>如果你的团队主要成员是Java开发人员，或者如果你的网络应用程序不需要其它ICEfaces没有的复杂组件，又或者如果你的网络应用程序是事件驱动的，那么使用ICEfaces是很好的选择。如果你的网路应用是事件驱动的，请确定你已经了解ICEfaces不提供真正的“服务器推”技术的，HTML5，Flash Builder 4和Silverlight都支持的。不过，相应地ICEfaces使用长轮询的方法来模拟服务器推技术。</p>
<p>使用ICEfaces的网站有波音，美国航空航天局，联合太平洋公司，T-Mobile，以及美国银行。</p>
<p><strong><a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a> Flash Builder 4</strong></p>
<p>Flash已经出现了很长一段时间，但是用使用Flash来构建整个网络应用十分麻烦，直到Flex的引进，这是Flash的一个扩展，提供RIA网络组 件。</p>
<p><a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a> Flash Builder  4最令人兴奋的是它的跨平台和跨浏览器特性，允许程序在所有的操作系统和所有的浏览器上以同样的方式运行。相比于<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>，浏览器有不同的 <a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>引擎管理和处理的代码，而<a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a>的Flash只有一个引擎，用户通过<a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a>  Flash浏览器插件来安装（通常的情况是他们有了）。</p>
<p>Flash Builder 4  应用之所以能如此，因为它们已经嵌入到HTML页面，这意味着浏览器本身并没有对应用程序的性能有什么影响。这意味着你如果你乐意，  你还可以在IE6上运行最复杂的网络应用程序。（这当然简单，因为Flash插件/引擎经常会更新，因此只是稍微依赖于用户插件的版本）。</p>
<p>这些应用通常是伴随着服务器端处理，比如一个Java后端处理，而且需要Flash Builder 4IDE做开发。</p>
<p>如果你的团队主要是Java开发（因为搭配Java运作良好），或者你的应用程序使用事件驱动的构架，可以选择<a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a> Flash Builder  4。</p>
<p>使用Flash作为网络应用程序的网站有Mint.com，Flickr和Hyundai。</p>
<p><strong>Silverlight</strong></p>
<p>Silverlight是基本上微软版本的<a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a> Flex /的<a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a> Flash。现在已获得了一些吸引力，但似乎并没有达到的<a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a>  Flash的普及程度。</p>
<p>Silverlight应用程序明显约束于.NET的后端，因为它是微软的产品。这意味着，你不得不 Silverlight /.NET 和<a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a>  Flex / [一些服务器端脚本，如PHP] 之间整合考虑。</p>
<p>如果你的网络应用需要复杂的图形，或者如果你的团队主要是.NET开发人员，又或者如果你的应用程序使用事件驱动的架构，那你可以选择 Silverlight。</p>
<p>使用Silverlight的网站，如Netflix。</p>
<p><strong>HTML5</strong></p>
<p>HTML5的是RIA运动中的最新发展。  HTML5，在本质上是HTML4，<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>，<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">CSS</a>，<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">Javascript</a>代码库以及Falsh的最优合并，利用API模型成为一个单一规 范。 HTML5的是一个开放的技术，这意味着不会有单一的主管团体如Flash的<a href="http://www.iwanna.cn/tags/adobe/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Adobe">Adobe</a>或Silverlight的微软。</p>
<p>由于HTML5规范还没有完成，IE9尚未发布，要建立产品级的网络应用，你还需要等待一点点时间。</p>
<p>目前，所有主要浏览器除了IE8都支持HTML5。由于IE8的浏览器市场占据了主要部分，在IE9发布之前，HTML5实在难以成为主流。</p>
<p>一旦HTML5得到广泛支持，如果你不想购买和学习的IDE（像Flex和Silverlight框架所必需的），如果你的应用程序使用事件驱动架构，或 者如果你喜欢使用内置的HTML功能和<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a> API 功能而不是使用第三方<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>库，那么使用HTML是很好的选择。</p>
<p>尽管HTML5中可以很好地处理图形，但是使用Flash和Silverlight来处理复杂图形和动画在目前仍然容易/更快的选择。</p>
<p><strong>RIA 的未来</strong><br />
<a href="http://www.iwanna.cn/" target="_blank"><img src="http://images.uheed.com/iwanna/2010/07/27/13154422012391927.jpg" alt="使用框架建立富联网应用 | iwanna.cn 我想网" /></a></p>
<p>HTML5应用程序是互联网的未来吗？不完全是。只要那些创造性和创新性的网络开发人员还在不断的去创造一些特别的东西，就会总是出现一些新技术可以造出 些HTML5或其他任何网络技术无法完成的神奇的东西。</p>
<p><a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>库，ICEfaces，Flash，Silverlight和HTML5的存在首要原因是其创造力和创新性。未来的网络将会由许多 共存的技术组成，就像现在。</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/27/4752/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/27/4752/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/27/4752/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/27/4752/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/27/4752/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/adobe/" title="Adobe" rel="tag nofollow">Adobe</a>, <a href="http://www.iwanna.cn/tags/adobe/" title="Adobe" rel="tag nofollow">Adobe</a>, <a href="http://www.iwanna.cn/topics/ui/javascript/ajax/" title="Ajax" rel="tag nofollow">Ajax</a>, <a href="http://www.iwanna.cn/tags/ajax/" title="Ajax" rel="tag nofollow">Ajax</a>, <a href="http://www.iwanna.cn/tags/flash/" title="Flash" rel="tag nofollow">Flash</a>, <a href="http://www.iwanna.cn/topics/ui/adobe/flash-adobe-ui/" title="Flash" rel="tag nofollow">Flash</a>, <a href="http://www.iwanna.cn/topics/ui/adobe/flex-adobe-ui/" title="Flex" rel="tag nofollow">Flex</a>, <a href="http://www.iwanna.cn/topics/ui/html/" title="HTML" rel="tag nofollow">HTML</a>, <a href="http://www.iwanna.cn/tags/html/" title="HTML" rel="tag nofollow">HTML</a>, <a href="http://www.iwanna.cn/topics/ui/javascript/" title="JavaScript" rel="tag nofollow">JavaScript</a>, <a href="http://www.iwanna.cn/tags/javascript/" title="JavaScript" rel="tag nofollow">JavaScript</a>, <a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/topics/ui/javascript/mootools-javascript-ui/" title="MooTools" rel="tag nofollow">MooTools</a>, <a href="http://www.iwanna.cn/tags/ria/" title="RIA" rel="tag nofollow">RIA</a>, <a href="http://www.iwanna.cn/tags/silverlight/" title="Silverlight" rel="tag nofollow">Silverlight</a>, <a href="http://www.iwanna.cn/topics/news/technology_news/" title="Technology" rel="tag nofollow">Technology</a>, <a href="http://www.iwanna.cn/topics/ui/javascript/yui/" title="YUI" rel="tag nofollow">YUI</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2009/04/29/894/" title="页面输出时一些常用的小技巧 (2009年04月29日)">页面输出时一些常用的小技巧</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/07/03/1913/" title="使用Adobe Flex 3开发(MMO)大型多人在线游戏 (2009年07月3日)">使用Adobe Flex 3开发(MMO)大型多人在线游戏</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/23/1862/" title="XmlHttpRequest的串行异步 (2009年06月23日)">XmlHttpRequest的串行异步</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/07/29/2073/" title="RIA特别专题和Flash开发平台工具下载资源发布 (2009年07月29日)">RIA特别专题和Flash开发平台工具下载资源发布</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/12/4478/" title="Ajax跨域访问解决方案 (2010年07月12日)">Ajax跨域访问解决方案</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/04/20/713/" title="24 个漂亮的个性化 HTML 表单技术 (2009年04月20日)">24 个漂亮的个性化 HTML 表单技术</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/16/4013/" title="10个绝妙的HTML5，CSS和Javascript示例 (2010年06月16日)">10个绝妙的HTML5，CSS和Javascript示例</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/02/04/2487/" title="10个基于 JavaScript 的 WYSIWYG 编辑器 (2010年02月4日)">10个基于 JavaScript 的 WYSIWYG 编辑器</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/21/1854/" title="10个关于Ajax的IT人需要知道的事情 (2009年06月21日)">10个关于Ajax的IT人需要知道的事情</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/21/3284/" title="10个Google 推动的 AJAX 库 API (2010年05月21日)">10个Google 推动的 AJAX 库 API</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/27/4752/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>21个演示展示强大的jQuery特效</title>
		<link>http://www.iwanna.cn/archives/2010/07/23/4691/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/23/4691/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 14:18:33 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4691</guid>
		<description><![CDATA[就在不久之前, Flash 是被web设计师用来为网站添加交互的重要技术之一！自从Ipad诞生, 并且不支持 Flash Player,  加速了web开发中使用其他技术代替flash，比如 jQuery, Ajax 还有其它。
尽管在很多情况下Flash在仍然是一个非常强大和有用的工具,web设计师习惯于用flash完成一些特效，但这些都能用jQuery轻松实现！下面有 21 个在线的演示来显示jQuery在制作高级特效和交互方面的强大能力，可以媲美Flash！
1. Flip! 一个 jQuery 插件
这个演示 模仿流行的卡片翻转的效果，可以360度旋转自身，x或y维度！


2. jQuery Quicksand 插件
这是一个强大的插件用来在页面上排序数组的元素/图标,有酷的渐入 /渐出和动画特效！

3. ImageFlow
这个图像浏览器和苹果的CoverFlow界面很相似，让用户能够很熟悉他们的产品和应用！

4. 用jQuery代替flash建立一个交互性地图
这个演示展示了jQuery用ajax技术创造迷人的界面的强大能力！

5. 用jQuery &#38; CSS3滑出消息
点击+号用漂亮的光滑的动画效果展示附加的信息！

6. Zoomer Gallery
在这个演示中看起来静态的画廊被multi-layer zoom特效变得富有交互性，当移到图像上时会产生缩放！

7. jQuery Circulate
这个演示展示了滚球的粒子效果，所有的特效都是用jQuery

8. Photo Zoom Out Effect
这个也是一个图像伸缩的特效，看起来静止的画面，会随着你的鼠标移过而变得富有生机！

9. Sliding Boxes and Captions with jQuery
这里我们可以看到原本只能被flash开发者创造的过渡特效，现在使用jQuery一样可以办到！

10. CSS3 Lightbox Gallery
这个插件看起来是为媒体展示图片特别制作的，你可以任意拖拽图片达到图片拼接的效果，你还可以单击放大图片！这是一个强大的图片展示特效！你还可以  用API使用ajax技术让人们分享图片到Flickr，twitter，Facebook或者其他网站！当然中国的新浪微博、人人网、开心网也能！

11. 用jQuery和CSS3创造一个拍照效果！
一眼看去这个演示像游戏狙击，乍一看居然是拍照功能！这是一个很强大的工具，当用AJAX或者HTML5本地存储时，用来对付特别大的图像！

12. Awesome Bubble Navigation-可怕的泡沫导航效果
开发者用色彩变换和动画创造出一个非常吸引人的并且富有交互性的菜单！

13. Beautiful Background Image Navigation
酷炫的图片展示特效，用来做导航会有惊人的效果！

14. [...]]]></description>
			<content:encoded><![CDATA[<p>就在不久之前, Flash 是被web设计师用来为网站添加交互的重要技术之一！自从Ipad诞生, 并且不支持 Flash Player,  加速了web开发中使用其他技术代替flash，比如 <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>, <a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">Ajax</a> 还有其它。<br />
尽管在很多情况下Flash在仍然是一个非常强大和有用的工具,web设计师习惯于用flash完成一些特效，但这些都能用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>轻松实现！下面有 <strong><a href="http://www.iwanna.cn/archives/2010/07/23/4691/" title="21个演示展示强大的jQuery特效">21 个在线的演示来显示jQuery在制作高级特效</a></strong>和交互方面的强大能力，可以媲美Flash！</p>
<p><strong>1. Flip! 一个 <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> 插件</strong></p>
<p>这个演示 模仿流行的卡片翻转的效果，可以360度旋转自身，x或y维度！</p>
<p><a href="http://lab.smashup.it/flip/"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-11.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a><br />
<span id="more-4691"></span><br />
<strong>2. <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> Quicksand 插件</strong></p>
<p>这是一个强大的插件用来在页面上排序数组的元素/图标,有酷的渐入 /渐出和动画特效！</p>
<p><a href="http://razorjack.net/quicksand/"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-2.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>3. ImageFlow</strong></p>
<p>这个图像浏览器和苹果的CoverFlow界面很相似，让用户能够很熟悉他们的产品和应用！</p>
<p><a href="http://imageflow.finnrudolph.de/"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-3.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>4. 用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>代替flash建立一个交互性地图</strong></p>
<p>这个演示展示了<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>用<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">ajax</a>技术创造迷人的界面的强大能力！</p>
<p><a href="http://www.gethifi.com/blog/a-jquery-plugin-for-zoomable-interactive-maps"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-4.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="398" /></a></p>
<p><strong>5. 用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> &amp; CSS3滑出消息</strong></p>
<p>点击+号用漂亮的光滑的动画效果展示附加的信息！</p>
<p><a href="http://demo.tutorialzine.com/2010/04/slideout-context-tips-jquery-css3/demo.html"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-5.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>6. Zoomer Gallery</strong></p>
<p>在这个演示中看起来静态的画廊被multi-layer zoom特效变得富有交互性，当移到图像上时会产生缩放！</p>
<p><a href="http://addyosmani.com/blog/zoomer-gallery-a-jquery-plugin-for-displaying-images-with-flash-like-zooming-effects/"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-6.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="405" /></a></p>
<p><strong>7. <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> Circulate</strong></p>
<p>这个演示展示了滚球的粒子效果，所有的特效都是用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a></p>
<p><a href="http://css-tricks.com/examples/Circulate/"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-7.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>8. Photo Zoom Out Effect</strong></p>
<p>这个也是一个图像伸缩的特效，看起来静止的画面，会随着你的鼠标移过而变得富有生机！</p>
<p><a href="http://www.tympanus.net/Tutorials/PhotoZoomOutEffect/"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-8.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="405" /></a></p>
<p><strong>9. Sliding Boxes and Captions with <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a></strong></p>
<p>这里我们可以看到原本只能被flash开发者创造的过渡特效，现在使用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>一样可以办到！</p>
<p><a href="http://images.uheed.com/iwanna/2010/07/23/jquery/image-9.jpg"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-9.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>10. CSS3 Lightbox Gallery</strong></p>
<p>这个插件看起来是为媒体展示图片特别制作的，你可以任意拖拽图片达到图片拼接的效果，你还可以单击放大图片！这是一个强大的图片展示特效！你还可以  用API使用<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">ajax</a>技术让人们分享图片到Flickr，twitter，Facebook或者其他网站！当然中国的新浪微博、人人网、开心网也能！</p>
<p><a href="http://demo.tutorialzine.com/2009/11/hovering-gallery-css3-jquery/demo.php"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-10.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>11. 用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>和CSS3创造一个拍照效果！</strong></p>
<p>一眼看去这个演示像游戏狙击，乍一看居然是拍照功能！这是一个很强大的工具，当用<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">AJAX</a>或者HTML5本地存储时，用来对付特别大的图像！</p>
<p><a href="http://images.uheed.com/iwanna/2010/07/23/jquery/image-111.jpg"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-111.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>12. Awesome Bubble Navigation-可怕的泡沫导航效果</strong></p>
<p>开发者用色彩变换和动画创造出一个非常吸引人的并且富有交互性的菜单！</p>
<p><a href="http://tympanus.net/Tutorials/BubbleNavigation/"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-12.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="404" /></a></p>
<p><strong>13. Beautiful Background Image Navigation</strong></p>
<p>酷炫的图片展示特效，用来做导航会有惊人的效果！</p>
<p><a href="http://images.uheed.com/iwanna/2010/07/23/jquery/image-13.jpg"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-13.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>14. AviaSlider</strong></p>
<p>AviaSlider采用经典的类似Flash的过渡效果，以强化滑块界面。</p>
<p><a href="http://images.uheed.com/iwanna/2010/07/23/jquery/image-14.jpg"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-14.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="402" /></a></p>
<p><strong>15. Background Image Slideshow</strong></p>
<p>动画背景的地方flash用来支配的网页设计之一。这里有一个例子使用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>代替。</p>
<p><a href="http://demo.marcofolio.net/bgimg_slideshow/"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-15.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>16. Panning Slideshow</strong></p>
<p>另一个独特采取典型幻灯片界面。在这里，笔者增加了对角线导航的接口，并使其脱颖而出。</p>
<p><a href="http://s3.amazonaws.com/buildinternet/live-tutorials/panning-slideshow/panning-slideshow.htm"><img title="image (16)" src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-16.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="400" /></a></p>
<p><strong>17. jqFancyTransitions</strong></p>
<p>这个插件可以用来显示作为一个具有奇特法拉盛般的幻灯片过渡效果的照片。</p>
<p><a href="http://workshop.rs/projects/jqfancytransitions/"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-17.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="405" /></a></p>
<p><strong>18. iCarousel – Horizontal images slider</strong></p>
<p>另一个幻灯片，添加了缓和的过渡和真的挺身而出。这也难怪他们选择在此演示，展示性感的Mac产品。</p>
<p><a href="http://zendold.lojcomm.com.br/icarousel/example6.asp"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-18.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>19. Making an Interactive Picture with <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a></strong></p>
<p>该演示可用于拍摄的网站那里有很多优势的屏幕空间。该网站上发现的第一个模式框点击它显示更多关于点击部分的信息。</p>
<p><a href="http://static.buildinternet.com/live-tutorials/interactive-picture/index.html"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-19.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>20. Cloud Zoom</strong></p>
<p>一个插件，看起来好像是在考虑电子商务设计。云缩放易于实现，能真正提高用户的体验。</p>
<p><a href="http://www.professorcloud.com/mainsite/cloud-zoom.htm"><img title="image (20)" src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-20.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><strong>21. Apple-like Retina Effect</strong></p>
<p>任何人谁使用了一iPhone，iPod的触摸，或ipad，将扩大在屏幕上时，你碰了长时间的面积小面积熟悉。此演示实现这个桌面效果。</p>
<p><a href="http://images.uheed.com/iwanna/2010/07/23/jquery/image-21.jpg"><img src="http://images.uheed.com/iwanna/2010/07/23/jquery/image-21.jpg" alt="21个演示展示强大的jQuery特效 | iwanna.cn 我想网" width="500" height="406" /></a></p>
<p><em>专为WDD编译 <a href="http://www.designtopx.com/" target="_blank">Kalim 舰队,</a> 。他是一个专业网站设计者和博客与超过6年的经验。这个网站是他的激情,他自己的时间写博客的分裂,软件的发展和社会的媒体。他喜欢使用和开发新的应用网 络、移动、桌面。</em></p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/23/4691/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/23/4691/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/23/4691/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/23/4691/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/23/4691/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/plugin/" title="Plugin" rel="tag nofollow">Plugin</a>, <a href="http://www.iwanna.cn/topics/develope/plugin-develope/" title="Plugin" rel="tag nofollow">Plugin</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2010/07/11/4460/" title="推荐8个独特应用的JQuery拖放插件 (2010年07月11日)">推荐8个独特应用的JQuery拖放插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/04/23/811/" title="FCBKcomplete v 2.02 (2009年04月23日)">FCBKcomplete v 2.02</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/01/1621/" title="6个jQuery图标插件的应用程序 (2009年06月1日)">6个jQuery图标插件的应用程序</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/08/4164/" title="50个表单功能，验证，安全和自定义化的jQuery插件 (2010年07月8日)">50个表单功能，验证，安全和自定义化的jQuery插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/08/2812/" title="30个最好的jQuery表单插件 (2010年05月8日)">30个最好的jQuery表单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/01/26/2474/" title="30+ 新鲜惊奇的 jQuery 插件与教程 (2010年01月26日)">30+ 新鲜惊奇的 jQuery 插件与教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/14/2913/" title="2010年4月：最佳的jQuery插件 (2010年05月14日)">2010年4月：最佳的jQuery插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/07/4401/" title="10+个jQuery图片滚动插件介绍 (2010年07月7日)">10+个jQuery图片滚动插件介绍</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/26/3379/" title="10 个帮助你处理Web页面层布局的jQuery插件 (2010年05月26日)">10 个帮助你处理Web页面层布局的jQuery插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/23/4691/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery源码分析-each函数</title>
		<link>http://www.iwanna.cn/archives/2010/07/20/4644/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/20/4644/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 14:25:46 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[程序源码]]></category>
		<category><![CDATA[Source-code]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4644</guid>
		<description><![CDATA[/*!
 * jQuery源码分析-each函数
 * jQuery版本:1.4.2
 *
 * &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-
 * 函数介绍
 *
 * each函数通过jQuery.extend函数附加到jQuery对象中：
 * jQuery.extend({
 *     each: function() {}
 * });

 * 如果对jQuery.extend函数源码还不了解,可以参考《jQuery源码分析-extend函数》一文
 *
 * jQuery.each方法用于遍历一个数组或对象,并对当前遍历的元素进行处理
 * jQuery.each方法可以为处理函数增加附带的参数(带参数与不带参数的回调使用方法不完全一致)
 *
 * &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-
 * 使用说明
 * each函数根据参数的类型实现的效果不完全一致：
 * 1、遍历对象(有附加参数)
 * $.each(Object, function(p1, p2) {
 *     this;    [...]]]></description>
			<content:encoded><![CDATA[<p>/*!<br />
 * <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>源码分析-each函数<br />
 * <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>版本:1.4.2<br />
 *<br />
 * &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
 * 函数介绍<br />
 *<br />
 * each函数通过<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.extend函数附加到<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>对象中：<br />
 * <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.extend({<br />
 *     each: function() {}<br />
 * });<br />
<span id="more-4644"></span><br />
 * 如果对<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.extend函数源码还不了解,可以参考《<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>源码分析-extend函数》一文<br />
 *<br />
 * <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.each方法用于遍历一个数组或对象,并对当前遍历的元素进行处理<br />
 * <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.each方法可以为处理函数增加附带的参数(带参数与不带参数的回调使用方法不完全一致)<br />
 *<br />
 * &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
 * 使用说明<br />
 * each函数根据参数的类型实现的效果不完全一致：<br />
 * 1、遍历对象(有附加参数)<br />
 * $.each(Object, function(p1, p2) {<br />
 *     this;      //这里的this指向每次遍历中Object的当前属性值<br />
 *     p1; p2;    //访问附加参数<br />
 * }, ['参数1', '参数2']);<br />
 *<br />
 * 2、遍历数组(有附件参数)<br />
 * $.each(Array, function(p1, p2){<br />
 *     this;      //这里的this指向每次遍历中Array的当前元素<br />
 *     p1; p2;    //访问附加参数<br />
 * }, ['参数1', '参数2']);<br />
 *<br />
 * 3、遍历对象(没有附加参数)<br />
 * $.each(Object, function(name, value) {<br />
 *     this;     //this指向当前属性的值<br />
 *     name;     //name表示Object当前属性的名称<br />
 *     value;    //value表示Object当前属性的值<br />
 * });<br />
 *<br />
 * 4、遍历数组(没有附加参数)<br />
 * $.each(Array, function(i, value) {<br />
 *     this;     //this指向当前元素<br />
 *     i;        //i表示Array当前下标<br />
 *     value;    //value表示Array当前元素<br />
 * });<br />
 * &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
 *<br />
 */<br />
//<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.each(), $.each()<br />
//@param {Object}|{Array} object 需要遍历处理的对象或数组<br />
//@param {Function} callback 遍历处理回调函数<br />
//@param {Array} args callback回调函数的附加参数<br />
each: function(object, callback, args){</p>
<p>    //当需要遍历的是一个对象时,name变量用于记录对象的属性名<br />
    var name,    </p>
<p>    //当需要遍历的是一个数组时,i变量用于记录循环的数组下标<br />
    i = 0,    </p>
<p>    //遍历数组长度,当需要遍历的对象是一个数组时存储数组长度<br />
    //如果需要遍历的是一个对象,则length === undefined<br />
    length = object.length,    </p>
<p>    //检查第1个参数object是否是一个对象<br />
    //根据object.length排除数组类型，根据isFunction排除函数类型(因为函数也是对象)<br />
    isObj = length === undefined || <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.isFunction(object);</p>
<p>    //回调函数具有附加参数时,执行第一个分支<br />
    //if(!!args) {<br />
    if (args) {</p>
<p>        //需要遍历的是一个对象<br />
        if (isObj) {</p>
<p>            //遍历对象属性,name是对象的属性名,再函数顶部已声明<br />
            //许多人不太习惯for(var name in object)方式,如果不进行声明,则name就会被定义为全局变量<br />
            for (name in object) {</p>
<p>                //调用callback回调函数,且回调函数的作用域表示为当前属性的值<br />
                //如:callback() {  this; //函数中的this指向当前属性值<br />
                //将each的第3个参数args作为回调函数的附加参数<br />
                if (callback.apply(object[name], args) === false) {</p>
<p>                    //如果在callback回调函数中使用return false;则不执行下一次循环<br />
                    break;<br />
                }<br />
            }<br />
        }<br />
        //需要遍历的是一个数组<br />
        else {</p>
<p>            //循环长度,循环变量i在函数顶部已定义<br />
            //循环变量的自增在循环内部执行<br />
            for (; i &amp;lt; length;) {</p>
<p>                //调用callback函数,与上面注释的callback调用一致<br />
                //此处callback函数中的this指向当前数组元素<br />
                if (callback.apply(object[i++], args) === false) {<br />
                    break;<br />
                }<br />
            }<br />
        }</p>
<p>    }<br />
    //回调函数没有附加参数时,执行第二个分支<br />
    else {</p>
<p>        //需要遍历的是一个对象<br />
        if (isObj) {</p>
<p>            //循环对象的属性名,name在函数顶部已定义<br />
            for (name in object) {</p>
<p>                //调用callback回调函数<br />
                //在不带参数的对象遍历中,作用域表示为当前属性的值<br />
                //且回调函数包含两个参数,第一个数当前属性名,第二个是当前属性值<br />
                //我觉得这句代码修改一下会更好用：if(callback.call(object, name, object[name]) === false) {<br />
                if (callback.call(object[name], name, object[name]) === false) {</p>
<p>                    //如果在callback回调函数中使用return false;则不执行下一次循环<br />
                    break;<br />
                }<br />
            }<br />
        }<br />
        //需要遍历的是一个数组<br />
        else {<br />
            //这里的for写法有点BT,解释为：<br />
            //var value = object[0];<br />
            //for(; i &amp;lt; length;) {<br />
            //    if(false === callback.call(value, i, value)) {<br />
            //        break;<br />
            //    }<br />
            //    value = object[++i];<br />
            //}<br />
            //同样,我觉得这里的代码稍加修改会更好用:<br />
            //for (; i &amp;lt; length &amp;&amp; false !== callback.call(object, i, object[i++]);) {<br />
            //}<br />
            for (var value = object[0]; i &amp;lt; length &amp;&amp; callback.call(value, i, value) !== false; value = object[++i]) {<br />
            }<br />
        }<br />
    }</p>
<p>    //这里返回遍历的对象或数组,但object没有被更改,因此一般不给$.each()赋值<br />
    //但是如果按照我在注释中所修改的写法来使用,且在callback回调函数中对this(即对object的引用)进行了修改<br />
    //则这里返回的object是被修改后的对象或数组<br />
    return object;<br />
}</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/20/4644/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/20/4644/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/20/4644/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/20/4644/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/20/4644/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/source-code/" title="Source-code" rel="tag nofollow">Source-code</a>, <a href="http://www.iwanna.cn/topics/resource/" title="程序源码" rel="tag nofollow">程序源码</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4797/" title="实用jquery代码片段集合[下] (2010年07月29日)">实用jquery代码片段集合[下]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4795/" title="实用jquery代码片段集合[上] (2010年07月29日)">实用jquery代码片段集合[上]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/03/29/2605/" title="基于jQuery的新闻图片 (2010年03月29日)">基于jQuery的新闻图片</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/13/4506/" title="推荐9个jquery手风琴菜单插件 (2010年07月13日)">推荐9个jquery手风琴菜单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/11/4460/" title="推荐8个独特应用的JQuery拖放插件 (2010年07月11日)">推荐8个独特应用的JQuery拖放插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/23/1864/" title="如何为您的博客图片添加水印效果？ (2009年06月23日)">如何为您的博客图片添加水印效果？</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/09/4451/" title="基本代码安全知识 (2010年07月9日)">基本代码安全知识</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/17/4583/" title="制作jquery文字提示插件 (2010年07月17日)">制作jquery文字提示插件</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/20/4644/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jquery表单操作总结</title>
		<link>http://www.iwanna.cn/archives/2010/07/18/4602/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/18/4602/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 05:52:35 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4602</guid>
		<description><![CDATA[文本框，文本区域：
1.清空内容
$(&#8220;#txt&#8221;).attr(&#8220;value&#8221;,&#8221;");
2.填充内容
$(&#8220;#txt&#8221;).attr(&#8220;value&#8221;,&#8221;11&#8243;);
3.取值
方法一：var textval = $(&#8220;#txt&#8221;).attr(&#8220;value&#8221;);
方法二：var textval = $(&#8220;#text&#8221;).val();

单选组radio
1.获取一组radio被选中项的值
方法一：var value = $(&#8216;input[@name=items][@checked]&#8216;).val();
方法二：var value = $(&#8220;input[@type=radio][@checked]&#8220;).val();
2.设置单选组radio的第二个元素为当前选中值
$(&#8216;input[@name=items]&#8216;).get(1).checked = true;
3.设置value=2的项目为当前选中项
$(&#8220;input[@type=radio]&#8220;).attr(&#8220;checked&#8221;,&#8217;2&#8242;);
下拉框select
1.获取select被选中项的文本
var text = $(&#8220;select[@name=items] option[@selected]&#8220;).text();
2.获取select被选中项的值
var value = $(&#8216;#sel&#8217;).val();
3.下拉框select的第二个元素为当前选中值
$(&#8216;#select_id&#8217;)[0].selectedIndex = 1;
4.设置value=-sel3的项目为当前选中项
$(&#8220;#sel&#8221;).attr(&#8220;value&#8221;,&#8217;-sel3&#8242;);
5.添加下拉框的option
$(&#8220;&#60;option value=&#8217;1&#8242;&#62;1111&#60;/option&#62;&#60;option  value=&#8217;2&#8242;&#62;2222&#60;/option&#62;&#8221;).appendTo(&#8220;#sel&#8221;);
6.清空下拉框
$(&#8220;#sel&#8221;).empty()；
多选框checkbox：
1.不打勾
$(&#8220;#chk1&#8243;).attr(&#8220;checked&#8221;,&#8221;);
2.打勾
$(&#8220;#chk2&#8243;).attr(&#8220;checked&#8221;,true);
3.判断是否已经打勾
if($(&#8220;#chk1&#8243;).attr(&#8216;checked&#8217;)==undefined)
4.取值
var checkboxval = $(&#8220;#checkbox_id&#8221;).attr(&#8220;value&#8221;)；
5.多选框checkbox被选中的个数
$(&#8216;input[name=id[]][checked]&#8216;).length
6.判断多选框checkbox是否至少有一个选中
if($(&#8216;input[name=id[]][checked]&#8216;).length == 0)
表单form
提交表单
$(&#8216;#form1&#8242;).submit(function() {});

© 我想网 Akon 所有 , 2010. &#124;
永久链接 &#124;
没有评论 &#124;
提交到
Google Reader
鲜果
抓虾


	标签：JQuery, JQuery

	您可能会感兴趣的其他文章
	
	简单的JQuery聚光灯效果教程 
	用jQuery和CSS构建下拉菜单 
	推荐9个jquery手风琴菜单插件 
	推荐8个独特应用的JQuery拖放插件 
	实用jquery代码片段集合[下] 
	实用jquery代码片段集合[上] 
	如何为您的博客图片添加水印效果？ 
	基于jQuery的新闻图片 
	制作jquery文字提示插件 
	初探 jQuery 的 Sizzle [...]]]></description>
			<content:encoded><![CDATA[<p>文本框，文本区域：<br />
1.清空内容<br />
$(&#8220;#txt&#8221;).attr(&#8220;value&#8221;,&#8221;");<br />
2.填充内容<br />
$(&#8220;#txt&#8221;).attr(&#8220;value&#8221;,&#8221;11&#8243;);<br />
3.取值<br />
方法一：var textval = $(&#8220;#txt&#8221;).attr(&#8220;value&#8221;);<br />
方法二：var textval = $(&#8220;#text&#8221;).val();<br />
<span id="more-4602"></span><br />
单选组radio<br />
1.获取一组radio被选中项的值<br />
方法一：var value = $(&#8216;input[@name=items][@checked]&#8216;).val();<br />
方法二：var value = $(&#8220;input[@type=radio][@checked]&#8220;).val();<br />
2.设置单选组radio的第二个元素为当前选中值<br />
$(&#8216;input[@name=items]&#8216;).get(1).checked = true;<br />
3.设置value=2的项目为当前选中项<br />
$(&#8220;input[@type=radio]&#8220;).attr(&#8220;checked&#8221;,&#8217;2&#8242;);<br />
下拉框select<br />
1.获取select被选中项的文本<br />
var text = $(&#8220;select[@name=items] option[@selected]&#8220;).text();<br />
2.获取select被选中项的值<br />
var value = $(&#8216;#sel&#8217;).val();<br />
3.下拉框select的第二个元素为当前选中值<br />
$(&#8216;#select_id&#8217;)[0].selectedIndex = 1;<br />
4.设置value=-sel3的项目为当前选中项<br />
$(&#8220;#sel&#8221;).attr(&#8220;value&#8221;,&#8217;-sel3&#8242;);<br />
5.添加下拉框的option<br />
$(&#8220;&lt;option value=&#8217;1&#8242;&gt;1111&lt;/option&gt;&lt;option  value=&#8217;2&#8242;&gt;2222&lt;/option&gt;&#8221;).appendTo(&#8220;#sel&#8221;);<br />
6.清空下拉框<br />
$(&#8220;#sel&#8221;).empty()；<br />
多选框checkbox：<br />
1.不打勾<br />
$(&#8220;#chk1&#8243;).attr(&#8220;checked&#8221;,&#8221;);<br />
2.打勾<br />
$(&#8220;#chk2&#8243;).attr(&#8220;checked&#8221;,true);<br />
3.判断是否已经打勾<br />
if($(&#8220;#chk1&#8243;).attr(&#8216;checked&#8217;)==undefined)<br />
4.取值<br />
var checkboxval = $(&#8220;#checkbox_id&#8221;).attr(&#8220;value&#8221;)；<br />
5.多选框checkbox被选中的个数<br />
$(&#8216;input[name=id[]][checked]&#8216;).length<br />
6.判断多选框checkbox是否至少有一个选中<br />
if($(&#8216;input[name=id[]][checked]&#8216;).length == 0)<br />
表单form<br />
提交表单<br />
$(&#8216;#form1&#8242;).submit(function() {});</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/18/4602/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/18/4602/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/18/4602/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/18/4602/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/18/4602/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/13/4506/" title="推荐9个jquery手风琴菜单插件 (2010年07月13日)">推荐9个jquery手风琴菜单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/11/4460/" title="推荐8个独特应用的JQuery拖放插件 (2010年07月11日)">推荐8个独特应用的JQuery拖放插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4797/" title="实用jquery代码片段集合[下] (2010年07月29日)">实用jquery代码片段集合[下]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4795/" title="实用jquery代码片段集合[上] (2010年07月29日)">实用jquery代码片段集合[上]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/23/1864/" title="如何为您的博客图片添加水印效果？ (2009年06月23日)">如何为您的博客图片添加水印效果？</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/03/29/2605/" title="基于jQuery的新闻图片 (2010年03月29日)">基于jQuery的新闻图片</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/17/4583/" title="制作jquery文字提示插件 (2010年07月17日)">制作jquery文字提示插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/17/4574/" title="初探 jQuery 的 Sizzle 选择器 (2010年07月17日)">初探 jQuery 的 Sizzle 选择器</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/18/4602/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>35个 jQuery的动画教程</title>
		<link>http://www.iwanna.cn/archives/2010/07/17/4598/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/17/4598/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 05:26:23 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Menu]]></category>
		<category><![CDATA[Translate]]></category>
		<category><![CDATA[Query]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[翻译]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4598</guid>
		<description><![CDATA[创意设计人员可以利用JQuery做一些惊人的事情。实现各种各样的动画效果都是可能的，这里提供的35个JQuery教程就是为想在这方面获得技能提升的任何人最好的学习资源。你会发现一些创建动画导航菜单的教程，及使用JQuery实现不以来Flash也可以实现的动画效果。Enjoy it！
Animate  Image Filling Up Using jQuery


Animate  Curtains Opening with jQuery

Building  an Animated Cartoon Robot with jQuery

jQuery  Animations: A 7-Step Program

jQuery  and CSS Sprite Animation Explained in Under 5 Minutes

Fun  with jQuery’s Animate () Function

Animate a Hover  with jQuery

How  to Create a “MooTools Homepage” Inspired Navigation Effect [...]]]></description>
			<content:encoded><![CDATA[<p>创意设计人员可以利用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">JQuery</a>做一些惊人的事情。实现各种各样的动画效果都是可能的，这里提供的<strong><a href="http://www.iwanna.cn/archives/2010/07/17/4598/" title="35个 jQuery的动画教程">35个JQuery教程</a></strong>就是为想在这方面获得技能提升的任何人最好的学习资源。你会发现一些创建动画导航菜单的教程，及使用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">JQuery</a>实现不以来Flash也可以实现的动画效果。Enjoy it！</p>
<p><a href="http://buildinternet.com/2009/06/animate-image-filling-up-using-jquery/" target="_blank"><strong>Animate  Image Filling Up Using jQuery</strong></a><br />
<span id="more-4598"></span><br />
<a href="http://buildinternet.com/2009/06/animate-image-filling-up-using-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-21.jpg" alt="Animate Image  Filling Up Using jQuery" width="500" height="285" /></a></p>
<p><a href="http://buildinternet.com/2009/07/animate-curtains-opening-with-jquery/" target="_blank"><strong>Animate  Curtains Opening with jQuery</strong></a></p>
<p><a href="http://buildinternet.com/2009/07/animate-curtains-opening-with-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-20.jpg" alt="Animate Curtains  Opening with jQuery" width="500" height="319" /></a></p>
<p><strong><a href="http://css-tricks.com/jquery-robot/" target="_blank">Building  an Animated Cartoon Robot with jQuery</a></strong></p>
<p><a href="http://css-tricks.com/jquery-robot/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-1.jpg" alt="Building an Animated  Cartoon Robot with jQuery" width="500" height="261" /></a></p>
<p><a href="http://net.tutsplus.com/tutorials/javascript-ajax/jquery-animations-a-7-step-program/" target="_blank"><strong>jQuery  Animations: A 7-Step Program</strong></a></p>
<p><a href="http://net.tutsplus.com/tutorials/javascript-ajax/jquery-animations-a-7-step-program/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-6.jpg" alt="jQuery Animations: A  7-Step Program" width="500" height="292" /></a></p>
<p><a href="http://addyosmani.com/blog/jquery-sprite-animation/" target="_blank"><strong>jQuery  and CSS Sprite Animation Explained in Under 5 Minutes</strong></a></p>
<p><a href="http://addyosmani.com/blog/jquery-sprite-animation/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-29.jpg" alt="jQuery and CSS  Sprite Animation Explained in Under 5 Minutes" width="500" height="208" /></a></p>
<p><strong><a href="http://www.viget.com/inspire/fun-with-jquerys-animation-function/" target="_blank">Fun  with jQuery’s Animate () Function</a></strong></p>
<p><a href="http://www.viget.com/inspire/fun-with-jquerys-animation-function/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-2.jpg" alt="Fun with jQuery's  Animate () Function" width="500" height="200" /></a></p>
<p><strong><a href="http://www.incg.nl/blog/2008/hover-block-jquery/" target="_blank">Animate a Hover  with jQuery</a></strong></p>
<p><a href="http://www.incg.nl/blog/2008/hover-block-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-3.jpg" alt="Animate a Hover with  jQuery" width="500" height="338" /></a></p>
<p><strong><a href="http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-mootools-homepage-inspired-navigation-effect-using-jquery/" target="_blank">How  to Create a “MooTools Homepage” Inspired Navigation Effect Using jQuery</a></strong></p>
<p><a href="http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-mootools-homepage-inspired-navigation-effect-using-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-4.jpg" alt="How to Create a " width="500" height="345" /></a></p>
<p><a href="http://buildinternet.com/2009/08/crafting-an-animated-postcard-with-jquery/" target="_blank"><strong>Crafting  an Animated Postcard with jQuery</strong></a></p>
<p><a href="http://buildinternet.com/2009/08/crafting-an-animated-postcard-with-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-16.jpg" alt="Crafting an  Animated Postcard with jQuery" width="500" height="211" /></a></p>
<p><strong><a href="http://net.tutsplus.com/tutorials/html-css-techniques/how-to-create-a-drop-down-nav-menu-with-html5-css3-and-jquery/" target="_blank">How  to Create a Drop-Down Nav Menu with HTML5, CSS3 and jQuery</a></strong></p>
<p><a href="http://net.tutsplus.com/tutorials/html-css-techniques/how-to-create-a-drop-down-nav-menu-with-html5-css3-and-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-5.jpg" alt="How to Create a  Drop-Down Nav Menu with HTML5, CSS3 and jQuery" width="500" height="190" /></a></p>
<p><a href="http://www.marcofolio.net/webdesign/creating_a_polaroid_photo_viewer_with_css3_and_jquery.html" target="_blank"><strong>Creating  a Polaroid Photo Viewer with CSS3 and jQuery</strong></a></p>
<p><a href="http://www.marcofolio.net/webdesign/creating_a_polaroid_photo_viewer_with_css3_and_jquery.html" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-28.jpg" alt="Creating a  Polaroid Photo Viewer with CSS3 and jQuery" width="500" height="310" /></a></p>
<p><strong><a href="http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-easy-sequential-animations-in-jquery/" target="_blank">Quick  Tip: Easy Sequential Animations in jQuery</a></strong></p>
<p><a href="http://net.tutsplus.com/tutorials/javascript-ajax/quick-tip-easy-sequential-animations-in-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-7.jpg" alt="Quick Tip: Easy  Sequential Animations in jQuery" width="500" height="262" /></a></p>
<p><strong><a href="http://net.tutsplus.com/javascript-ajax/build-a-top-panel-with-jquery/" target="_blank">Build  an Incredible Login Form with jQuery</a></strong></p>
<p><a href="http://net.tutsplus.com/javascript-ajax/build-a-top-panel-with-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-8.jpg" alt="Build an Incredible  Login Form with jQuery" width="500" height="286" /></a></p>
<p><strong><a href="http://css-tricks.com/revealing-photo-slider/" target="_blank">Learning jQuery:  Revealing Photo Slider</a></strong></p>
<p><a href="http://css-tricks.com/revealing-photo-slider/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-9.jpg" alt="Learning jQuery:  Revealing Photo Slider" width="500" height="391" /></a></p>
<p><strong><a href="http://snook.ca/archives/javascript/jquery-bg-image-animations/" target="_blank">Using  jQuery for Background Image Animations</a></strong></p>
<p><a href="http://snook.ca/archives/javascript/jquery-bg-image-animations/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-10.jpg" alt="Using jQuery for  Background Image Animations" width="500" height="305" /></a></p>
<p><strong><a href="http://www.shopdev.co.uk/blog/animated-menus-using-jquery/" target="_blank">Animated  Menus Using jQuery</a></strong></p>
<p><a href="http://www.shopdev.co.uk/blog/animated-menus-using-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-11.jpg" alt="Animated Menus  Using jQuery" width="500" height="326" /></a></p>
<p><strong><a href="http://net.tutsplus.com/javascript-ajax/create-a-cool-animated-navigation-with-css-and-jquery/" target="_blank">Create  a Cool Animated Navigation with CSS and jQuery</a></strong></p>
<p><a href="http://net.tutsplus.com/javascript-ajax/create-a-cool-animated-navigation-with-css-and-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-12.jpg" alt="Create a Cool  Animated Navigation with CSS and jQuery" width="500" height="160" /></a></p>
<p><strong><a href="http://www.clarklab.net/blog/posts/animated-drop-down-menu-with-jquery/" target="_blank">Animated  Drop Down Menu with jQuery</a></strong></p>
<p><a href="http://www.clarklab.net/blog/posts/animated-drop-down-menu-with-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-13.jpg" alt="Animated Drop Down  Menu with jQuery" width="500" height="312" /></a></p>
<p><strong><a href="http://net.tutsplus.com/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/" target="_blank">How  to Load In and Animate Content with jQuery</a></strong></p>
<p><a href="http://net.tutsplus.com/javascript-ajax/how-to-load-in-and-animate-content-with-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-14.jpg" alt="How to Load In and  Animate Content with jQuery" width="500" height="279" /></a></p>
<p><strong><a href="http://www.gayadesign.com/diy/puffing-smoke-effect-in-jquery/" target="_blank">Puffing  Smoke Effect in jQuery</a></strong></p>
<p><a href="http://www.gayadesign.com/diy/puffing-smoke-effect-in-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-15.jpg" alt="Puffing Smoke  Effect in jQuery" width="500" height="387" /></a></p>
<p><strong><a href="http://buildinternet.com/2009/02/how-to-make-an-impressive-animated-landscape-header-with-jquery/" target="_blank">How  to Make an Impressive Animated Landscape Header with jQuery</a></strong></p>
<p><a href="http://buildinternet.com/2009/02/how-to-make-an-impressive-animated-landscape-header-with-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-17.jpg" alt="How to Make an  Impressive Animated Landscape Header with jQuery" width="500" height="263" /></a></p>
<p><strong><a href="http://buildinternet.com/2009/05/make-an-animated-alphabet-using-keypress-events-in-jquery/" target="_blank">Make  an Animated Alphabet Using Keypress Events in jQuery</a></strong></p>
<p><a href="http://buildinternet.com/2009/05/make-an-animated-alphabet-using-keypress-events-in-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-18.jpg" alt="Make an Animated  Alphabet Using Keypress Events in jQuery" width="500" height="273" /></a></p>
<p><strong><a href="http://buildinternet.com/2009/01/how-to-make-a-smooth-animated-menu-with-jquery/" target="_blank">How  to Make a Smooth Animated Menu with jQuery</a></strong></p>
<p><a href="http://buildinternet.com/2009/01/how-to-make-a-smooth-animated-menu-with-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-19.jpg" alt="How to Make a  Smooth Animated Menu with jQuery" width="500" height="173" /></a></p>
<p><strong><a href="http://buildinternet.com/2009/03/sliding-boxes-and-captions-with-jquery/" target="_blank">Sliding  Boxes and Captions with jQuery</a></strong></p>
<p><a href="http://buildinternet.com/2009/03/sliding-boxes-and-captions-with-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-22.jpg" alt="Sliding Boxes and  Captions with jQuery" width="500" height="270" /></a></p>
<p><strong><a href="http://www.adrianpelletier.com/2009/05/31/create-a-realistic-hover-effect-with-jquery-ui/" target="_blank">Create  a Realistic Hover Effect with jQuery</a></strong></p>
<p><a href="http://www.adrianpelletier.com/2009/05/31/create-a-realistic-hover-effect-with-jquery-ui/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-23.jpg" alt="Create a Realistic  Hover Effect with jQuery" width="500" height="206" /></a></p>
<p><strong><a href="http://visitmix.com/labs/glimmer/samples/freestyle.html" target="_blank">Glimmer  “Freestyle” Animations</a></strong></p>
<p><a href="http://visitmix.com/labs/glimmer/samples/freestyle.html" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-24.jpg" alt="Glimmer " width="500" height="346" /></a></p>
<p><strong><a href="http://blog.themeforest.net/tutorials/create-a-funky-parallax-background-effect-using-jquery/" target="_blank">Create  a Funky Parallax Background Effect Using jQuery</a></strong></p>
<p><a href="http://blog.themeforest.net/tutorials/create-a-funky-parallax-background-effect-using-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-25.jpg" alt="Create a Funky  Parallax Background Effect Using jQuery" width="500" height="248" /></a></p>
<p><strong><a href="http://www.queness.com/post/620/create-a-stunning-sliding-door-effect-with-jquery" target="_blank">Create  a Stunning Sliding Door Effect with jQuery</a></strong></p>
<p><a href="http://www.queness.com/post/620/create-a-stunning-sliding-door-effect-with-jquery" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-26.jpg" alt="Create a Stunning  Sliding Door Effect with jQuery" width="500" height="286" /></a></p>
<p><strong><a href="http://www.devirtuoso.com/2009/07/how-to-build-an-animated-header-in-jquery/" target="_blank">How  to Build an Animated Header in jQuery</a></strong></p>
<p><a href="http://www.devirtuoso.com/2009/07/how-to-build-an-animated-header-in-jquery/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-27.jpg" alt="How to Build an  Animated Header in jQuery" width="500" height="170" /></a></p>
<p><strong><a href="http://usejquery.com/posts/3/create-a-unique-gallery-by-using-z-index-and-jquery" target="_blank">Create  a Unique Gallery by Using Z-Index and jQuery</a></strong></p>
<p><a href="http://usejquery.com/posts/3/create-a-unique-gallery-by-using-z-index-and-jquery" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-30.jpg" alt="Create a Unique  Gallery by Using Z-Index and jQuery" width="500" height="405" /></a></p>
<p><strong><a href="http://blarnee.com/wp/jquery-ui-animation-effects/" target="_blank">jQuery UI  Animation Effects</a></strong></p>
<p><a href="http://blarnee.com/wp/jquery-ui-animation-effects/" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-31.jpg" alt="jQuery UI Animation  Effects" width="500" height="324" /></a></p>
<p><strong><a href="http://www.jankoatwarpspeed.com/post/2008/12/13/Animate-your-message-boxes-with-jQuery.aspx" target="_blank">Animate  Your Message Boxes with jQuery</a></strong></p>
<p><a href="http://www.jankoatwarpspeed.com/post/2008/12/13/Animate-your-message-boxes-with-jQuery.aspx" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-32.jpg" alt="Animate Your  Message Boxes with jQuery" width="500" height="315" /></a></p>
<p><strong><a href="http://davidwalsh.name/animate-opacity" target="_blank">Sexy Opacity Animation  with MooTools or jQuery</a></strong></p>
<p><a href="http://davidwalsh.name/animate-opacity" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-33.jpg" alt="Sexy Opacity  Animation with MooTools or jQuery" width="500" height="221" /></a></p>
<p><strong><a href="http://interactivevolcano.com/jquery-animation-timing" target="_blank">Controlling  Animation Timing in jQuery</a></strong></p>
<p><a href="http://interactivevolcano.com/jquery-animation-timing" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-34.jpg" alt="Controlling  Animation Timing in jQuery" width="500" height="343" /></a></p>
<p><strong><a href="http://www.packtpub.com/article/methods-for-animation-effects-with-jquery-1.4" target="_blank">Methods  for Animation Effects with jQuery 1.4</a></strong></p>
<p><a href="http://www.packtpub.com/article/methods-for-animation-effects-with-jquery-1.4" target="_blank"><img src="http://vanimg.s3.amazonaws.com/ani-35.jpg" alt="Methods for  Animation Effects with jQuery 1.4" width="500" height="229" /></a></p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/17/4598/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/17/4598/#comments">1条评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/17/4598/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/17/4598/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/17/4598/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/topics/ui/menu/" title="Menu" rel="tag nofollow">Menu</a>, <a href="http://www.iwanna.cn/tags/menu/" title="Menu" rel="tag nofollow">Menu</a>, <a href="http://www.iwanna.cn/tags/query/" title="Query" rel="tag nofollow">Query</a>, <a href="http://www.iwanna.cn/tags/translate/" title="Translate" rel="tag nofollow">Translate</a>, <a href="http://www.iwanna.cn/topics/iwanna/translate-iwanna/" title="Translate" rel="tag nofollow">Translate</a>, <a href="http://www.iwanna.cn/tags/tutorial/" title="Tutorial" rel="tag nofollow">Tutorial</a>, <a href="http://www.iwanna.cn/tags/translates/" title="翻译" rel="tag nofollow">翻译</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/07/04/1880/" title="30个写给HTML初学者的最佳实践 (2009年07月4日)">30个写给HTML初学者的最佳实践</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/03/19/2583/" title="20 个使用Photoshop进行高品质的网页设计教程 (2010年03月19日)">20 个使用Photoshop进行高品质的网页设计教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/02/20/2527/" title="10个令人惊异的创建按钮的CSS3教程、方法 (2010年02月20日)">10个令人惊异的创建按钮的CSS3教程、方法</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/07/01/1896/" title="10个PHP实现的超酷的操作。 (2009年07月1日)">10个PHP实现的超酷的操作。</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/07/05/1923/" title="转换设计原图 PSD 为 HTML (2009年07月5日)">转换设计原图 PSD 为 HTML</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/22/3294/" title="深色调社交图标：免费且高质量的社交媒体图标集 (2010年05月22日)">深色调社交图标：免费且高质量的社交媒体图标集</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/18/3210/" title="如何正确购买一个已经存在的域名(SEO友好) (2010年05月18日)">如何正确购买一个已经存在的域名(SEO友好)</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/27/1176/" title="如何备份所有的浏览器 &#8211; 5 个小贴士(Google Chrome, Firefox, Safari, Internet Explorer, and Opera) (2009年05月27日)">如何备份所有的浏览器 &#8211; 5 个小贴士(Google Chrome, Firefox, Safari, Internet Explorer, and Opera)</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/11/1046/" title="基本指南 &#8211; CSS处理大背景图片 (2009年05月11日)">基本指南 &#8211; CSS处理大背景图片</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/17/4598/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>制作jquery文字提示插件</title>
		<link>http://www.iwanna.cn/archives/2010/07/17/4583/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/17/4583/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 17:30:21 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4583</guid>
		<description><![CDATA[很多朋友向明河请教如何写jquery插件，今天在浏览tutorialzine时 候有篇教程讲解如何写个jquery文字提示插件，这插件很简单，很适合用于讲解jquery插件机制，明河也借此抛砖引玉先讲解具体一个插件，这个插件 名为：Colortip，然后在下篇教程讲解jquery插件机制。
效果如下图，鼠标滑过链接出现文字提示，提示框的背景颜色可以自由控制。


查看示例
源码下载


制作教程
一、功能讲解

1、鼠标经过带有”title”属性的容器，出现title中的内容（一般是链接、图片）
2、可以控制提示框的背景颜色

二、创建html结构
最重要的是title属性，此属性用于控制提示框出现的内容。
class=”blue”用于控制提示框的背景颜色。
当你第一次滑过该容器时，会创建如下提示框容器：

&#60;a class=&#8221;blue colorTipContainer&#8221; href=&#8221;http://www.iwanna.cn/archives/2010/07/17/4583/&#8221;&#62;推荐9个jquery手风琴菜单插件
 &#60;span class=&#8221;colorTip&#8221; style=&#8221;margin-left:  -60px;&#8221;&#62;推荐9个jquery手风 琴菜单插件

 &#60;span class=&#8221;pointyTipShadow&#8221;&#62;&#60;/span&#62;

 &#60;span class=&#8221;pointyTip&#8221;&#62;&#60;/span&#62;

 &#60;/span&#62;
&#60;/a&#62;

css部分的内容不是讲解关键，明河予以略过。
三、插件代码colortip-1.0-jquery.js

(function($){
 $.fn.colorTip = function(settings){

 var defaultSettings = {
 //颜色
 color        : &#8216;yellow&#8217;,
 //延迟
 timeout        : 500
 }
 //提示框的颜色
 var supportedColors = ['red','green','blue','white','yellow','black'];

 /* 合并默认参数和用户自定义参数 */
 [...]]]></description>
			<content:encoded><![CDATA[<p>很多朋友向明河请教如何写<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>插件，今天在浏览<a href="http://tutorialzine.com/2010/07/colortips-jquery-tooltip-plugin/" target="_blank">tutorialzine</a>时 候有篇教程讲解如何写个<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>文字提示插件，这插件很简单，很适合用于讲解<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>插件机制，明河也借此抛砖引玉先讲解具体一个插件，这个插件 名为：<strong>Colortip</strong>，然后在下篇教程讲解<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>插件机制。</p>
<p>效果如下图，鼠标滑过链接出现文字提示，提示框的背景颜色可以自由控制。</p>
<p><img title="colortips" src="http://images.uheed.com/iwanna/2010/07/17/colortips.png" alt="" width="473" height="200" /></p>
<ul class="tow-columns clearfix">
<li class="l"><a target="_blank" class="btn-view-demo" href="http://www.iwanna.cn/examples/js/jquery-tooltip-plugin/colortips.html">查看示例</a></li>
<li class="l"><a class="btn-download" title="$.colorTip——jquery文字提示插件" href="http://www.iwanna.cn/examples/js/jquery-tooltip-plugin/colortips.rar">源码下载</a></li>
</ul>
<p><span id="more-4583"></span></p>
<h2>制作教程</h2>
<h4>一、功能讲解</h4>
<ul>
<li>1、鼠标经过带有”title”属性的容器，出现title中的内容（一般是链接、图片）</li>
<li>2、可以控制提示框的背景颜色</li>
</ul>
<h4>二、创建html结构</h4>
<p>最重要的是title属性，此属性用于控制提示框出现的内容。<br />
class=”blue”用于控制提示框的背景颜色。<br />
当你第一次滑过该容器时，会创建如下提示框容器：</p>
<ol title="Double click to hide line number.">
<li>&lt;a class=&#8221;blue colorTipContainer&#8221; href=&#8221;http://www.iwanna.cn/archives/2010/07/17/4583/&#8221;&gt;推荐9个<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>手风琴菜单插件</li>
<li> &lt;span class=&#8221;colorTip&#8221; style=&#8221;margin-left:  -60px;&#8221;&gt;推荐9个<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>手风 琴菜单插件</li>
<li></li>
<li> &lt;span class=&#8221;pointyTipShadow&#8221;&gt;&lt;/span&gt;</li>
<li></li>
<li> &lt;span class=&#8221;pointyTip&#8221;&gt;&lt;/span&gt;</li>
<li></li>
<li> &lt;/span&gt;</li>
<li>&lt;/a&gt;</li>
</ol>
<p><a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a>部分的内容不是讲解关键，明河予以略过。</p>
<h4>三、插件代码colortip-1.0-<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>.js</h4>
<ol title="Double click to hide line number.">
<li>(function($){</li>
<li> $.fn.colorTip = function(settings){</li>
<li></li>
<li> var defaultSettings = {</li>
<li> //颜色</li>
<li> color        : &#8216;yellow&#8217;,</li>
<li> //延迟</li>
<li> timeout        : 500</li>
<li> }</li>
<li> //提示框的颜色</li>
<li> var supportedColors = ['red','green','blue','white','yellow','black'];</li>
<li></li>
<li> /* 合并默认参数和用户自定义参数 */</li>
<li> settings = $.extend(defaultSettings,settings);</li>
<li></li>
<li> return this.each(function(){</li>
<li></li>
<li> var elem = $(this);</li>
<li></li>
<li> // 如果该对象不包含title属性，直接予以返回</li>
<li> if(!elem.attr(&#8216;title&#8217;)) return true;</li>
<li></li>
<li> // 实例化eventScheduler（定时器）</li>
<li> var scheduleEvent = new eventScheduler();</li>
<li> //实例化Tip(提示类，产生、显示、隐藏)</li>
<li> var tip = new Tip(elem.attr(&#8216;title&#8217;));</li>
<li></li>
<li> // 产生提示框，并给提示框父容器添加样式</li>
<li></li>
<li> elem.append(tip.generate()).addClass(&#8216;colorTipContainer&#8217;);</li>
<li></li>
<li> // 检查提示框父容器是否有颜色样式</li>
<li></li>
<li> var hasClass = false;</li>
<li> for(var i=0;i&lt;supportedColors.length;i++)</li>
<li> {</li>
<li> if(elem.hasClass(supportedColors[i])){</li>
<li> hasClass = true;</li>
<li> break;</li>
<li> }</li>
<li> }</li>
<li></li>
<li> // 如果没有，使用默认的颜色</li>
<li></li>
<li> if(!hasClass){</li>
<li> elem.addClass(settings.color);</li>
<li> }</li>
<li></li>
<li> // 鼠标滑过提示框父容器时，显示提示框</li>
<li> // 鼠标移出，则隐藏</li>
<li></li>
<li> elem.hover(function(){</li>
<li></li>
<li> tip.show();</li>
<li></li>
<li> //清理定时器</li>
<li></li>
<li> scheduleEvent.clear();</li>
<li></li>
<li> },function(){</li>
<li></li>
<li> //启动定时器</li>
<li></li>
<li> scheduleEvent.set(function(){</li>
<li> tip.hide();</li>
<li> },settings.timeout);</li>
<li></li>
<li> });</li>
<li></li>
<li> //删除title属性</li>
<li> elem.removeAttr(&#8216;title&#8217;);</li>
<li> });</li>
<li></li>
<li> }</li>
<li></li>
<li></li>
<li> /*</li>
<li> /    定时器类</li>
<li> */</li>
<li></li>
<li> function eventScheduler(){}</li>
<li></li>
<li> eventScheduler.prototype = {</li>
<li> set    : function (func,timeout){</li>
<li> //添加定时器</li>
<li> this.timer = setTimeout(func,timeout);</li>
<li> },</li>
<li> clear: function(){</li>
<li> //清理定时器</li>
<li> clearTimeout(this.timer);</li>
<li> }</li>
<li> }</li>
<li></li>
<li></li>
<li> /*</li>
<li> /    提示类</li>
<li> */</li>
<li></li>
<li> function Tip(txt){</li>
<li> this.content = txt;</li>
<li> this.shown = false;</li>
<li> }</li>
<li></li>
<li> Tip.prototype = {</li>
<li> generate: function(){</li>
<li> //产生提示框</li>
<li></li>
<li> return this.tip || (this.tip = $(&#8216;&lt;span &gt;&#8217;+this.content+</li>
<li> &#8216;&lt;span  class=&#8221;pointyTipShadow&#8221;&gt;&lt;/span&gt;&lt;span  class=&#8221;pointyTip&#8221;&gt;&lt;/span&gt;&lt;/span&gt;&#8217;));</li>
<li> },</li>
<li> show: function(){</li>
<li> //显示提示框</li>
<li> if(this.shown) return;</li>
<li> this.tip.<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a>(&#8216;margin-left&#8217;,-this.tip.outerWidth()/2).fadeIn(&#8216;fast&#8217;);</li>
<li> this.shown = true;</li>
<li> },</li>
<li> hide: function(){</li>
<li> //隐藏提示框</li>
<li> this.tip.fadeOut();</li>
<li> this.shown = false;</li>
<li> }</li>
<li> }</li>
<li></li>
<li>})(<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>);</li>
</ol>
<p>关键代码注释明河已经翻译了，插件的制作思路，明河将在接下来的教程详解。</p>
<h4>四、<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>插件模板</h4>
<p><a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>插件是有固定的模板的，你大概大部分的<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>插件源码，会发现都有一套固定模板。<br />
模板如下：</p>
<ol title="Double click to hide line number.">
<li>(function($){</li>
<li> $.fn.插件名= function(settings){</li>
<li> //默认参数</li>
<li> var defaultSettings = {</li>
<li></li>
<li> }</li>
<li></li>
<li> /* 合并默认参数和用户自定义参数 */</li>
<li> settings = $.extend(defaultSettings,settings);</li>
<li></li>
<li> return this.each(function(){</li>
<li></li>
<li> });</li>
<li></li>
<li> }</li>
<li></li>
<li>})(<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>);</li>
</ol>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/17/4583/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/17/4583/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/17/4583/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/17/4583/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/17/4583/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/tutorial/" title="Tutorial" rel="tag nofollow">Tutorial</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/27/4767/" title="一个基于JQuery 和CSS3的滑动菜单 (2010年07月27日)">一个基于JQuery 和CSS3的滑动菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/02/4328/" title="CSS3+JQuery实现固定头部的导航菜单 (2010年07月2日)">CSS3+JQuery实现固定头部的导航菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/04/30/2887/" title="10个为Web设计师准备的jQuery教程 (2010年04月30日)">10个为Web设计师准备的jQuery教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/04/30/915/" title="解密CSS Sprites：技巧、工具和教程 (2009年04月30日)">解密CSS Sprites：技巧、工具和教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/13/4506/" title="推荐9个jquery手风琴菜单插件 (2010年07月13日)">推荐9个jquery手风琴菜单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/11/4460/" title="推荐8个独特应用的JQuery拖放插件 (2010年07月11日)">推荐8个独特应用的JQuery拖放插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/29/1215/" title="掌握强大的WordPress的子主题 (2009年05月29日)">掌握强大的WordPress的子主题</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4797/" title="实用jquery代码片段集合[下] (2010年07月29日)">实用jquery代码片段集合[下]</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/17/4583/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>初探 jQuery 的 Sizzle 选择器</title>
		<link>http://www.iwanna.cn/archives/2010/07/17/4574/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/17/4574/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 16:39:44 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4574</guid>
		<description><![CDATA[这是一篇关于介绍 jQuery  Sizzle选择器的文章.在文中，我试图用自己的语言配以适量的代码向读者展现出Sizzle在处理选择符时的流程原理，以及末了以少许文字给你展示出 如何借用Sizzle之手实现自定义选择器（也许更标准的叫法叫做过滤符）和它与YUI 选择器的大致比较。
前序
jQuery相比1.2的版本，在内部代码的构造上已经出现了巨大的变化，其之一便是模块的分发.我记得09年在jquery 9月开的一次大会上  john放出的一张ppt上  也指出了当前的jquery下一步目标，不仅仅是除了sizzle选择器的分离，届时core，attribute，css以及 manipulation，包括event也都会独立成单独的js文件.（1.4的文件结构，其实已经分成单独的16个模块的组成）
随着jQuery被用来构建web  app的场合愈来愈多，它的性能自然受到了大部分开发者的高度关注，它的内部实现机理又是如何，比如选择器的实现。

Sizzle，作为一个独立全新的选择 器引擎，出现在jQuery 1.3版本之后，并被John Resig作为一个开源的项目，可以用于其他框架：Mool, Dojo，YUI等。
好了，现在来看为什么Sizzle选择器如此受欢迎，使它能够在常用dom匹配上 都快于其他选择器而让这些框架们都垂青于它。
概要
一般选择器的匹配模式（包括jq1.2之前），都是一个顺序的思维方式，在需要递进式匹配时，比如$(‘div span’)  这样的匹配时，执行的操作都是先匹配页面中div然后再匹配它的节点下的span标签，之后返回结果。
Sizzle则采取了相反Right To  Left的实现方式，先搜寻页面中所有的span标签，再其后的操作中才去判断它的父节点（包括父节点以上）是否为div，是则压入数组，否则pass， 进入下一判断，最后返回该操作序列。
另外，在很多细节上也进行了优化。
浅析源码
在探索 $ 符 和 Sizzle的协同工作原理前，先引用一张图片.

开始吧。（$符在这里不作过多的介绍）.
当我们给$符传递进一个参数（也可能是多个）时，此时它会根据参数的类型（domElement &#124; string &#124; fn &#124;  array）进入不同的流程，在此，重点看 string  类型的处理，因为只有它才可以触发Sizzle。首先调用正则匹配看是否为创建dom节点的操作，然后看是否为简单id匹配，这一步也由正则匹配完成，否 则进入jQuery.fn.find()函数，由此进入Sizzle的天地。
当进入Sizzle时，一般情况下会配备三参：所要匹配的选择符，上下文，匹配的结果集。调用正则对传入的selector做一次”预匹配”.


var chunker = /((?:\((?:\([^()]+\)&#124;[^()]+)+\)&#124;\[(?:\[[^[\]]*\]&#124;['"][^'"]*['"]&#124;[^[\]'"]+)+\]&#124;\\.&#124;[^ &#38;gt;+~,(\[\\]+)+&#124;[&#38;gt;+~])(\s*,\s*)?/g,


让我们看一下一个简单选择器的实现过程：比如 div &#62;  p。我们要先找出符合条件的div[div]，再找出符合条件的p[p]，最后在上下文里[div]过滤出符合条件”&#62;”的p[p];抽象一点的说 法就是：在已知的上下文里，根据关系找出相应的节点。 他们靠关系联系起来。那么对于选择器的操作也就是根据关系来分组。一次次缩小上下文，直到找出符合条件的节点。
回到我们的话题，还是先看看这个令人费解的正则，相信你会有更好的分析方法，但是眼下，我还是一点点的拆分，让它表达的更清晰一点。先按照分组拆， 即():


((?:\((?:\([^()]+\)&#124;[^()]+)+\)&#124;\[(?:\[[^\[\]]*\]&#124;['"][^'"]*['"]&#124;[^\[\]'"]+)+\]&#124;\\.&#124;[^ &#38;gt;+~,(\[\\]+)+&#124;[&#38;gt;+~])
(\s*,\s*)?
((?:.&#124;\r&#124;\n)*)


第一行还是有点长，用’&#124;&#8217;拆分它:


1. (?:\((?:\([^()]+\)
2.[^()]+)+\)
3. \[(?:\[[^[\]]*\]
4. [...]]]></description>
			<content:encoded><![CDATA[<p>这是一篇关于介绍 <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>  Sizzle选择器的文章.在文中，我试图用自己的语言配以适量的代码向读者展现出Sizzle在处理选择符时的流程原理，以及末了以少许文字给你展示出 如何借用Sizzle之手实现自定义选择器（也许更标准的叫法叫做过滤符）和它与YUI 选择器的大致比较。</p>
<h3><strong>前序</strong></h3>
<p><a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>相比1.2的版本，在内部代码的构造上已经出现了巨大的变化，其之一便是模块的分发.我记得09年在<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a> 9月开的一次大会上  john放出的一张ppt上  也指出了当前的<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>下一步目标，不仅仅是除了sizzle选择器的分离，届时core，attribute，<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a>以及 manipulation，包括event也都会独立成单独的js文件.（1.4的文件结构，其实已经分成单独的<a href="http://github.com/jquery/jquery/tree/master/src" target="_blank">16</a>个模块的组成）</p>
<p>随着<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>被用来构建web  app的场合愈来愈多，它的性能自然受到了大部分开发者的高度关注，它的内部实现机理又是如何，比如选择器的实现。<br />
<span id="more-4574"></span><br />
<a href="http://sizzlejs.com/" target="_blank">Sizzle</a>，作为一个独立全新的选择 器引擎，出现在<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> 1.3版本之后，并被John Resig作为一个开源的项目，可以用于其他框架：Mool, Dojo，YUI等。</p>
<p>好了，现在来看为什么Sizzle选择器如此受欢迎，使它能够在<a href="http://ejohn.org/blog/selectors-that-people-actually-use/" target="_blank">常用dom匹配</a>上 都快于其他选择器而让这些框架们都垂青于它。</p>
<h3><strong>概要</strong></h3>
<p>一般选择器的匹配模式（包括jq1.2之前），都是一个顺序的思维方式，在需要递进式匹配时，比如$(‘div span’)  这样的匹配时，执行的操作都是先匹配页面中div然后再匹配它的节点下的span标签，之后返回结果。</p>
<p>Sizzle则采取了相反Right To  Left的实现方式，先搜寻页面中所有的span标签，再其后的操作中才去判断它的父节点（包括父节点以上）是否为div，是则压入数组，否则pass， 进入下一判断，最后返回该操作序列。</p>
<p>另外，在很多细节上也进行了优化。</p>
<h3><strong>浅析源码</strong></h3>
<p>在探索 $ 符 和 Sizzle的协同工作原理前，先引用一张图片.</p>
<p><a href="http://www.iwanna.cn" target="_blank"><img src="http://images.uheed.com/iwanna/2010/07/17/sizzle.jpg" alt="初探 jQuery 的 Sizzle 选择器" width="640" /></a></p>
<p>开始吧。（$符在这里不作过多的介绍）.</p>
<p>当我们给$符传递进一个参数（也可能是多个）时，此时它会根据参数的类型（domElement | string | fn |  array）进入不同的流程，在此，重点看 string  类型的处理，因为只有它才可以触发Sizzle。首先调用正则匹配看是否为创建dom节点的操作，然后看是否为简单id匹配，这一步也由正则匹配完成，否 则进入<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.fn.find()函数，由此进入Sizzle的天地。</p>
<p>当进入Sizzle时，一般情况下会配备三参：所要匹配的选择符，上下文，匹配的结果集。调用正则对传入的selector做一次”预匹配”.</p>
<pre>
<div>
<div>var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ &amp;gt;+~,(\[\\]+)+|[&amp;gt;+~])(\s*,\s*)?/g,</div>
</div>
</pre>
<p>让我们看一下一个简单选择器的实现过程：比如 div &gt;  p。我们要先找出符合条件的div[div]，再找出符合条件的p[p]，最后在上下文里[div]过滤出符合条件”&gt;”的p[p];抽象一点的说 法就是：在已知的<strong>上下文</strong>里，根据<strong>关系</strong>找出相应的<strong>节点</strong>。 他们靠关系联系起来。那么对于选择器的操作也就是根据关系来分组。一次次缩小上下文，直到找出符合条件的节点。</p>
<p>回到我们的话题，还是先看看这个令人费解的正则，相信你会有更好的分析方法，但是眼下，我还是一点点的拆分，让它表达的更清晰一点。先按照分组拆， 即():</p>
<pre>
<div>
<div>((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ &amp;gt;+~,(\[\\]+)+|[&amp;gt;+~])
(\s*,\s*)?
((?:.|\r|\n)*)</div>
</div>
</pre>
<p>第一行还是有点长，用’|&#8217;拆分它:</p>
<pre>
<div>
<div>1. (?:\((?:\([^()]+\)
2.[^()]+)+\)
3. \[(?:\[[^[\]]*\]
4. [^[\]]+)+\]|\\.
5.[^ &amp;gt;+~,(\[]+)+
6.[&amp;gt;+~]</div>
</div>
</pre>
<p>对于如div &gt; p。会得到数组结果['div','&gt;','p']。</p>
<p>对于更复杂的选择器，如div.classname &gt;  p.classname。会得到结果['div.classname','&gt;','p.classname']。</p>
<p>对于具有合并的‘,’,只是递归调用下获取结果再合并而已。过程开始变得简单起来。</p>
<p>对于普通的解析过程，我们遵循着从左到右的顺序即可完成我们的目标。</p>
<p>让我们总结下步骤：</p>
<div>
<pre>1.先查找页面上所有的div
2.循环所有的div，查找每个div下的p
3.合并结果
</pre>
</div>
<p>Sizzle用了截然相反的步骤：</p>
<div>
<pre>1.先查找页面上所有的p
2.循环所有的p，查找每个p的父元素
  1.如果不是div，遍历上一层。
  2.如果已经是顶层，排除此p。
  3.如果是div，则保存此p元素。
</pre>
</div>
<p>由子元素来查找父元素，能得到更好的效率。看，打破常规思维后不仅步骤更简单了，而且效率上也得到了些许提升。</p>
<p>所有的选择器都可以这样解析吗？不是，采用right -&gt; left的顺序是有前提条件的：没有位置关系的约束。</p>
<p>比如如下这段html：</p>
<pre>
<div>
<div>&lt;<a href="http://december.com/html/4/element/div.html" target="_blank">div</a>&gt;
p1content
p2content
&lt;/<a href="http://december.com/html/4/element/div.html" target="_blank">div</a>&gt;
&lt;<a href="http://december.com/html/4/element/div.html" target="_blank">div</a>&gt;
p3content
p4content
&lt;/<a href="http://december.com/html/4/element/div.html" target="_blank">div</a>&gt;</div>
</div>
</pre>
<p>对于选择器：$(“div p:first”)只会返回["#p1"]</p>
<p>而$(“div p:first-child”)则返回["#p1", "#p3"]</p>
<p>两者的区别在于位置filter的结果依赖于它前面的selector解析的结果，而其它  filter，只依赖于当前元素本身，就可以判断它是否满足filter。</p>
<p>那Sizzle是通过什么来判定进入哪一个流程呢，答案是origPOS的正则匹配,origPos指向了Expr中match对象的POS属性, 而POS中存储了五花八门的位置类约束，如下：</p>
<pre>
<div>
<div>/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/     //POS的值</div>
</div>
</pre>
<p>这样一来，第一步的流程判断就已明朗。</p>
<h5>当处于1的情况时:<a name="当处于1的情况时" target="_blank"> </a></h5>
<p>首先根据需要对当前处理的A数组元素进行一系列修正操作（Expr.relative主刀）。然后调用posProcess函数对修复后的元素进行 匹配.</p>
<p>其中，还需一层判断，如果有层级约束，eg ‘&gt;,’:input’ 会转化为 ‘&gt;  :input’,因为在最初调用chunker进行预匹配的时候，这些是会被分割为单个数组元素的，但在这里需要将它们做一次合并，这是由 posProcess所处理的数据格式所决定的</p>
<p>源码片段a:    — posProcess函数匹配核心</p>
<pre>
<div>
<div>//如果存在伪类选择符，从selector中移除，并保存在later中
// 这样一来，匹配对象便分离出来：selector（简单选择符存储器）和later（伪类选择符存储器）。
while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
    later += match[0];
    selector = selector.replace( Expr.match.PSEUDO, "" );
}
//构造selector，并调用Sizzle进行匹配,将结果存储在tmpSet中
selector = Expr.relative[selector] ? selector + "*" : selector;
for ( var i = 0, l = root.length; i &amp;lt; l; i++ ) {
    Sizzle( selector, root[i], tmpSet );
}
// 最后便是filter的过滤
return Sizzle.filter( later, tmpSet );</div>
</div>
</pre>
<p>源码片段b:    — 对预匹配后的数组A中元素的处理</p>
<pre>
<div>
<div>//这个为特例，被正则分割的A数组长度为2，则合并数组元素，上下文则原封不动为Sizzle传递进来的context。
if ( parts.length === 2 &amp;amp;&amp;amp; Expr.relative[ parts[0] ] ) {
    // 完成一次匹配， 由posProcess 内部调用 filter进行匹配
    // 但在匹配前，完成了一次连接选择符的操作
    // 存入set，注 set 当前还不是最终的结果，其这里的set和上面的tmpSet一样，都是一个"暂时性"的结果集
    set = posProcess( parts[0] + parts[1], context );</div>
</div>
</pre>
<p>源码片段c:    — 如果存在位置约束关系， 正向匹配。</p>
<pre>
<div>
<div>set = Expr.relative[ parts[0] ] ?
    [ context ] :
    // 否则对队列首元素进行一次简单匹配操作
    Sizzle( parts.shift(), context );</div>
</div>
</pre>
<p>分析Expr.relative，可以看出，它包含了4种dom元素间关系的判断，分别是 “+”, “&gt;”, “”, “~”</p>
<p>每一轮的匹配，都会先判断A数组的首元素是不是代表tag间关系符(+,&gt;等) ，而做后续处理.同时对A数组进行循环，依次做类似的处理</p>
<p>源码片段d     — 对A数组(parts)的循环处理及后续</p>
<pre>
<div>
<div>while ( parts.length ) {
    // 依次对 所匹配到的 数组中元素进行 递进匹配
    selector = parts.shift();
    //   '&amp;gt;'  -&amp;gt; '&amp;gt;input' 的形式
    if ( Expr.relative[ selector ] )
        selector += parts.shift();

    set = posProcess( selector, set );</div>
</div>
</pre>
<h5>当处于2的情况时:<a name="当处于2的情况时" target="_blank"> </a></h5>
<p>就有着不同之处,先看小片代码</p>
<p>源码片段e:    — 根据当前流程设置ret(两种情况)</p>
<pre>
<div>
<div>//为ret绑定正确的返回值
var ret = seed ?       //seed 为上一次调用sizzle返回值， 即前文中提到的set|tmpset
    //将预匹配后的A数组(parts)中的最后元素设置为ret的expr属性，set属性设为上一次匹配的结果集。
    { expr: parts.pop(), set: makeArray(seed) } :
    //如果是第一次调用，则进行匹配操作,调用find函数
    // 以parts数组最末元素为当前选择符，进行匹配操作，同时设置与之相关的context
    Sizzle.find( parts.pop(), parts.length === 1 &amp;amp;&amp;amp; context.parentNode ? context.parentNode : context, isXML(context) );</div>
</div>
</pre>
<p>2的情况为一般逻辑处理，从这小段代码便可得到Sizzle的匹配机制，每一次的调用都以数组末元素为基准，以上一次（或预设context）为上 下文约束关系以右到左的匹配,最后返回匹配结果。结合了DOM结构的特性，性能上也得到了大幅的提升。</p>
<p>我们知道选择器的类型是有效率差别的，id选择器效率最高，其次是class、name、tag、最后是最差的*表达式。在Sizzle.find 函数中，会按照这个效率的顺序查找元素，如果没有id就找class，依次下去。当然，class的支持需要方法 getElementsByClassName。如果没有，就只好从id跳到name。</p>
<pre>
<div>
<div>if ( document.getElementsByClassName &amp;amp;&amp;amp; document.documentElement.getElementsByClassName ) (function(){
    // ...
    // 如果支持直接获取，则将获取class的方法 直接添加进 Expr.order中   ['ID', 'NAME', 'TAG']
    Expr.order.splice(1, 0, "CLASS");
    //同时在find中追加对class的获取
    Expr.find.CLASS = function(match, context, isXML) {
        if ( typeof context.getElementsByClassName !== "undefined" &amp;amp;&amp;amp; !isXML ) {
            return context.getElementsByClassName(match[1]);
        }
    };
})();</div>
</div>
</pre>
<p>在Sizzle.find函数中，做了一系列的逻辑判断，来保证返回结果的正确性，首先在进入find时，保证了expr不为空的，然后根据表达式 类型(id|name|tag|class?)来选择与之对应的匹配分支进行实现，最后再做适当的收尾工作，将返回结果定义为对象，来移交给 filter,完成整个流程。</p>
<p>源码片段f:    — find 函数核心</p>
<pre>
<div>
<div>//order: [ "ID", "NAME", "TAG" ]
// 当然，如果浏览器支持对class的直接获取时，order中就会出现class的相关匹配规则
for ( var i = 0, l = Expr.order.length; i &amp;lt; l; i++ ) {
    var type = Expr.order[i], match;
    // 根据 type 对所传进来的expr 进行正则匹配
    // match中通过正则限制了这三类匹配方式的条件。
    // 1. ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
    // 2. NAME: /\[name=[&amp;#039;&amp;quot;]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)[&amp;#039;&amp;quot;]*\]/,
    // 3. TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,
    if ( (match = Expr.match[ type ].exec( expr )) ) {
        var left = RegExp.leftContext;
        //保证返回结果的正确性，如果存在\，则删除
        if ( left.substr( left.length - 1 ) !== &amp;quot;\\&amp;quot; ) {
            match[1] = (match[1] || &amp;quot;&amp;quot;).replace(/\\/g, &amp;quot;&amp;quot;);
            // 根据type调用 sizzle.selector.find方法获取结果集。
            set = Expr.find[ type ]( match, context, isXML );
            if ( set != null ) {
                //如果匹配成功，删除已经匹配的expr
                expr = expr.replace( Expr.match[ type ], &amp;quot;&amp;quot; );
                break;
            }
        }
    }
}

return {set: set, expr: expr};
};</div>
</div>
</pre>
<p>在所返回的对象中，expr的作用便是为了辅佐filter这把大器所需要完成任务的工具,到此就可以调用Sizzle.filter对 ret.set再做一次精确匹配(匹配规则即ret.expr),以及tag间的位置约束关系的匹配（这部分同1中类似）.</p>
<p>源码片段g:    — 和源码片段d有类似之处。不作详述</p>
<pre>
<div>
<div>    while ( parts.length ) {
        var cur = parts.pop(), pop = cur;
        // 是否存在 类似这样的匹配 eg:  '+',  '&amp;gt;'等
        if ( !Expr.relative[ cur ] ) {
            cur = "";
        } else {
            //如果存在层间关系的约束  则修复 cur 和pop的指向
            // eg  ['div', '+', 'span'] =&amp;gt;   pop = div;  cur = '+'; 并进入 relative的匹配。
            pop = parts.pop();
        }
        //  确保拥有上下文 代码略过
        Expr.relative[ cur ]( checkSet, pop, isXML(context) );
    }</div>
</div>
</pre>
<p>之后便接近sizzle尾声：结果集的处理(将所匹配的结果set 追加进 result中)。当然，如果有多表达式,便会再一次调用。</p>
<h3><strong>实例</strong></h3>
<p>以’div &gt; span p span:last’这个选择符为例，看看它的调用链是如何顺次完成的。</p>
<p>根据对源码的剖析，理解如下：</p>
<ol>
<li>1. <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>.init -&gt; <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>.prototype.find</li>
<li>2. 进入Sizzle(对xml的判断) -&gt; 设置parts数组等在匹配中所需要的元素 -&gt;  根据数组长度以及调用origPos进行判断，来决定进入哪个分支，在这个实例下进入分支1</li>
<li>3.  循环调用Sizzle进行匹配，将结果存入set中(因为在这一过程中是循环调用，所以对Sizzle的判断也是需要多次，进入哪一分支当然也会是不一样 的，比如第二轮循环判断则进入分支2中进行处理) ,对于&gt;号的处理，也会将它合并在其后的span中，构成新的选择符  ‘&gt;span’,然后进入Expr.relative进行匹配，同时调用posProcess。</li>
<li>4. 调用Sizzle.find  匹配除伪类以外的部分(即这里的选择器不包含:last),首先会调用Expr.find的find方法来判断是否为哪一类匹配，在这一实例中，为TAG 匹配。</li>
<li>5.  对从4步中生成的对象进行过滤,匹配’&gt;’(这一步的匹配是由Sizzle.filter触发，由Expr.relative完成),而在匹 配’span:last’时则由posProcess来触发，设置later值(:first)以及selector(span)，对span的匹配和4 步骤一样，重复匹配，而对:first的匹配则是第5步的重头戏，也就是调用Sizzle.filter来完成, 由此便生成了最后的匹配结果。</li>
</ol>
<p>对于有‘,’这样需要合并的选择器，Sizzle在获取结果后会按照文档流进行排序。所以，你可能会遇到这样的问题：把一个结果集append到新 的节点后，新的节点可能不会按照你书写的选择器的顺序出现。</p>
<p>以上，可以得出以下结论：大致通过如下步骤来完成：</p>
<div>
<pre>1.对表达式分组。
2.选择合适的处理顺序。
3.在当前的上下文里过滤要找的节点。并更新上下文。重复这一过程，直到结尾。
4.对结果排序，如果需要的话。
5.返回结果数组。
</pre>
</div>
<h3>前向兼容<a name="前向兼容" target="_blank"> </a></h3>
<h5>querySelectorAll<a name="Queryselectorall" target="_blank"> </a></h5>
<p>其实不止这一处，在Sizzle的<a href="http://wiki.github.com/jeresig/sizzle/" target="_blank">API手册</a>中Internal部分的find  函数（与filter构成了Sizzle的两把宝剑），在传递进该方法的参数可以用 <a href="http://www.w3.org/TR/selectors-api/" target="_blank">querySelectorAll()</a> （依赖于当前的浏览器执行环境） 直接获取时，它则直接调用该方法，既拥有了向前兼容的特性，又达到了速度的提升。</p>
<p>虽然有些环境实现了方法querySelectorAll，但是会有bug。</p>
<pre>
<div>
<div>//如果当前document 支持 querySelectorAll方法,则将浏览器可以完成的匹配完全交给浏览器
if ( document.querySelectorAll ) (function(){
    var oldSizzle = Sizzle;
    // 解决Safari bug 略过 ...
    Sizzle = function(<a href="http://www.iwanna.cn/tags/query/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Query">query</a>, context, extra, seed){
        context = context || document;

    // 因为querySelectorAll 在domElement 节点上操作时，存在bug 所以多了这样的判断
    // bug info: http://ejohn.org/blog/thoughts-on-queryselectorall/
        if ( !seed &amp;amp;&amp;amp; context.nodeType === 9 &amp;amp;&amp;amp; !isXML(context) ) {
            return makeArray( context.querySelectorAll(<a href="http://www.iwanna.cn/tags/query/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Query">query</a>), extra );
        }
        // querySelectorAll 可用则直接返回结果，否则才调用 sizzle
        return oldSizzle(<a href="http://www.iwanna.cn/tags/query/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Query">query</a>, context, extra, seed);
    };

    // oldSizzle 方法追加进 新的 Sizzle 中

})();</div>
</div>
</pre>
<p>对于任何一个开发者，我想，若浏览器原生已提供了实现方法，他都不会去高效而求繁琐吧。这一点在Sizzle中得到了充分的体现，总是尽可能的使用 相应环境下已实现的原生方法。所以在IE的低版本中(比如IE6)Sizzle的表现更加出众，在高级的浏览器中的对比却没有那么大的差别。</p>
<h3><strong>扩展</strong></h3>
<p>如何定义自己的选择器呢.如果项目中频繁使用某些过滤规则，是不是把它作为一个选择器更有效呢。<br />
既然<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">javascript</a>的对象可以任意扩充，只要我们访问得到，那么我们就可以很轻松得创建出自己的选择器</p>
<p>在<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.expr.filter对象中，有很多内置的选择器，比如  &#8216;disabled&#8217;,'text&#8217;,那我们就扩充它,比如，想寻找包含span的div元素</p>
<pre>
<div>
<div>// filter的简写  ':'
<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.expr[":"] = <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>.expr.filters;
$.extend($.expr[':'], {
    hasSpan: function(e) {
       return $(e).find('span').length &amp;gt; 0;
    }
});</div>
</div>
</pre>
<p>这样，我们就拥有了 &#8216;:hasSpan&#8217; 的选择器，使用当然和默认的一样。</p>
<pre>
<div>
<div>//直接用就可以了
$('div:hasSpan')....</div>
</div>
</pre>
<h3><strong>比较</strong></h3>
<p>再拾YUI3，在经过大幅度变化，以全新姿态出现，从选择器上的执行上效率不逊色于Sizzle几毫，初看YUI时就一直对它的模块细粒度化赞不绝 口，但是从如我这样的实用主义者的角度来看，选择器就应该是一个单独的模块，就如同<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>分离而出的Sizzle。但在YUI  term眼里，为了让代码的组织结构看上去更加的理想化，更加具有”YUI3“的特色，将之在代码结构上又细分出一二三，比起Sizzle的简洁，它显得 太过学院派。</p>
<p>除此，在选择器的扩展上，sizzle表现胜于YUI3  selector，在实现css1~css3选择器的基础上，又对常用的功能进行了扩展。比如对表单元素快捷操作。据我所知，开发者对这类型选择器的使用 频率并不是想象中那么低。既然有了模块的细分，为什么不将这部分作为一个可扩充性的功能点模块融入框架中呢。Sizzle于开发者就如同一块可口味佳的点 心，满足我们各式各样的胃口，简洁，不失其功能的强劲，这点非常值得称道。</p>
<p>总得来看，Sizzle与YUI就好象一个面向实际与理想主义的比较。这里没有对错之分，从不同角度来看，都能略窥其各自的禅意。前者从如何为开发 者带来便利的角度考虑，让开发者实时觉得它的简单可信赖。后者，也寄托了自己对web的构想，如果浏览器原生全部支持css3-selector，那岂不 是完全不用引入该模块了，不过我想，真到那时候，各框架也都会有很大的变化了，只是我对这一天的到来抱有比较消极的态度，这是后话。</p>
<h3><strong>总结</strong></h3>
<p>本文从总体上讨论了<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>之Sizzle选择器的实现原理，通过一个初步的流程分析，让各位读者对此有一个大致印象，毫无疑问，更深层次的匹 配，也只是它的递归调用，再匹配而已。</p>
<p>这里，没有做与其他框架在效率上的比较，如果你还对它的效率还有所怀疑的话，你可以<a href="http://yuilibrary.com/%7Emsweeney/yui-tests/slickspeed/" target="_blank">自行</a>比较。</p>
<p>如果你感兴趣，更推荐你继续去探索在1.4中着重优化的api源码，或许，会给你更多的启示</p>
<h3><strong>思考</strong></h3>
<p>从<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>的角度来讲，Sizzle的出现随之也带来了web上的一些新的局面，在追求效率的同时，即使是这类单种子模式的库也是需要将之分离 开来，来设计成能够独立使用，独立维护的引擎。</p>
<p>从选择器的角度来讲，Sizzle这次算法的提升，我初步的结论是它结合了DOM这一特定的数据结构，使其每次的匹配能够更精准,以此获得引擎效率 上的提升。</p>
<p>我们可否多想想，在思维的开拓上能给我们留下多少财富。很多问题的解决，在换一种新的思维方式后，是不是常常会有柳暗花明的感觉呢。</p>
<p>最后要申明的是，这篇文章是在<strong>导师</strong>一次次的指导下完成的，并且由我和<strong>obility</strong>共 同完成，再次谢谢<strong>导师</strong>和<strong>obility</strong>。</p>
<h3><strong>相关参考：</strong></h3>
<p>W3C <a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a> selector:<a href="http://www.w3.org/TR/REC-CSS1/" target="_blank">CSS1</a>,<a href="http://www.w3.org/TR/CSS2/selector.html" target="_blank">CSS2</a>,<a href="http://www.w3.org/TR/2001/CR-css3-selectors-20011113/" target="_blank">CSS3</a></p>
<p><a href="http://www.blooberry.com/indexdot/css/supportkey/syntax.htm" target="_blank">CSS  Support History</a> -Brian Wilson</p>
<p><a href="http://kimblim.dk/css-tests/selectors/" target="_blank">CSS  Selectors and Pseudo Selectors and browser support</a> &#8211; kimblim.dk</p>
<p><a href="http://paulirish.com/2008/javascript-css-selector-engine-timeline/" target="_blank">Javascript  CSS Selector Engine Timeline</a> &#8211; Paul Irish</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/17/4574/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/17/4574/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/17/4574/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/17/4574/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/17/4574/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/13/4506/" title="推荐9个jquery手风琴菜单插件 (2010年07月13日)">推荐9个jquery手风琴菜单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/11/4460/" title="推荐8个独特应用的JQuery拖放插件 (2010年07月11日)">推荐8个独特应用的JQuery拖放插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4797/" title="实用jquery代码片段集合[下] (2010年07月29日)">实用jquery代码片段集合[下]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4795/" title="实用jquery代码片段集合[上] (2010年07月29日)">实用jquery代码片段集合[上]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/23/1864/" title="如何为您的博客图片添加水印效果？ (2009年06月23日)">如何为您的博客图片添加水印效果？</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/03/29/2605/" title="基于jQuery的新闻图片 (2010年03月29日)">基于jQuery的新闻图片</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/17/4583/" title="制作jquery文字提示插件 (2010年07月17日)">制作jquery文字提示插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/04/09/280/" title="几种流行的AJAX框架jQuery,Mootools,Dojo,Ext JS的对比 (2009年04月9日)">几种流行的AJAX框架jQuery,Mootools,Dojo,Ext JS的对比</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/17/4574/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>常用JS验证函数总结</title>
		<link>http://www.iwanna.cn/archives/2010/07/13/4521/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/13/4521/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 14:46:51 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4521</guid>
		<description><![CDATA[随着做项目数量的越来越越多，其中用到js的地方很多相同，这 里自己整理了一些常用表单验证的js方法，虽然和其他js验证框架有一定的差距，但是毕竟是自己总结的一些东西，在此与纪录分享一下。

JS 验证/**
* 2010-7-13
* 贺  臣
* 情  缘
* js 各种表单数据验证
*/
/**************************************************************************************/
/*************************************数字的验 证*****************************************/
/**************************************************************************************/
/**
* 检查输入的一串字符是否全部是数字
* 输入:str  字符 串
* 返回:true 或 flase; true表示为数字
*/
function checkNum(str){
return str.match(/\D/) == null;
}
/**
* 检查输入的一串字符是否为小数
* 输入:str  字符串
* 返 回:true 或 flase; true表示为小数
*/
function checkDecimal(str){
if (str.match(/^-?\d+(\.\d+)?$/g) == null) {
return false;
}
else {
return true;
}
}
/**
* 检查输入的一串字符是否为整型数据
* 输入:str  字 符串
* 返回:true 或 flase; true表示为小数
*/
function checkInteger(str){
if (str.match(/^[-+]?\d*$/) == [...]]]></description>
			<content:encoded><![CDATA[<p>随着做项目数量的越来越越多，其中用到js的地方很多相同，这 里自己整理了一些常用表单验证的js方法，虽然和其他js验证框架有一定的差距，但是毕竟是自己总结的一些东西，在此与纪录分享一下。<br />
<span id="more-4521"></span><br />
JS 验证/**<br />
* 2010-7-13<br />
* 贺  臣<br />
* 情  缘<br />
* js 各种表单数据验证<br />
*/<br />
/**************************************************************************************/<br />
/*************************************数字的验 证*****************************************/<br />
/**************************************************************************************/</p>
<p>/**<br />
* 检查输入的一串字符是否全部是数字<br />
* 输入:str  字符 串<br />
* 返回:true 或 flase; true表示为数字<br />
*/<br />
function checkNum(str){<br />
return str.match(/\D/) == null;<br />
}</p>
<p>/**<br />
* 检查输入的一串字符是否为小数<br />
* 输入:str  字符串<br />
* 返 回:true 或 flase; true表示为小数<br />
*/<br />
function checkDecimal(str){<br />
if (str.match(/^-?\d+(\.\d+)?$/g) == null) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**<br />
* 检查输入的一串字符是否为整型数据<br />
* 输入:str  字 符串<br />
* 返回:true 或 flase; true表示为小数<br />
*/<br />
function checkInteger(str){<br />
if (str.match(/^[-+]?\d*$/) == null) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**************************************************************************************/<br />
/*************************************字符的验 证*****************************************/<br />
/**************************************************************************************/</p>
<p>/**<br />
* 检查输入的一串字符是否是字符<br />
* 输入:str  字符串<br />
* 返 回:true 或 flase; true表示为全部为字符 不包含汉字<br />
*/<br />
function checkStr(str){<br />
if (/[^\x00-\xff]/g.test(str)) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**<br />
* 检查输入的一串字符是否包含汉字<br />
* 输入:str  字符串<br />
* 返 回:true 或 flase; true表示包含汉字<br />
*/<br />
function checkChinese(str){<br />
if (escape(str).indexOf(&#8220;%u&#8221;) != -1) {<br />
return true;<br />
}<br />
else {<br />
return false;<br />
}<br />
}</p>
<p>/**<br />
* 检查输入的邮箱格式是否正确<br />
* 输入:str  字符串<br />
* 返 回:true 或 flase; true表示格式正确<br />
*/<br />
function checkEmail(str){<br />
if (str.match(/[A-Za-z0-9_-]+[@](\S*)(net|com|cn|org|cc|tv|[0-9]{1,3})(\S*)/g) == null) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**<br />
* 检查输入的手机号码格式是否 正确<br />
* 输入:str  字符串<br />
* 返回:true 或 flase; true表示格式正确<br />
*/<br />
function checkMobilePhone(str){<br />
if (str.match(/^(?:13\d|15[89])-?\d{5}(\d{3}|\*{3})$/) == null) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**<br />
* 检查输入的固定电话号码是否 正确<br />
* 输入:str  字符串<br />
* 返回:true 或 flase; true表示格式正确<br />
*/<br />
function checkTelephone(str){<br />
if (str.match(/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/) == null) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**<br />
* 检查QQ的格式是否正确<br />
* 输入:str  字符串<br />
*  返 回:true 或 flase; true表示格式正确<br />
*/<br />
function checkQQ(str){<br />
if (str.match(/^\d{5,10}$/) == null) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**<br />
* 检查输入的身份证号是否正确<br />
* 输入:str  字符串<br />
*  返 回:true 或 flase; true表示格式正确<br />
*/<br />
function checkCard(str){<br />
//15位数身份证正则表达式<br />
var arg1 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;<br />
//18位数身份证正则表达式<br />
var arg2 = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[A-Z])$/;<br />
if (str.match(arg1) == null &amp;&amp; str.match(arg2) == null) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**<br />
* 检查输入的IP地址是否正确<br />
* 输入:str  字符串<br />
*  返 回:true 或 flase; true表示格式正确<br />
*/<br />
function checkIP(str){<br />
var arg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;<br />
if (str.match(arg) == null) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**<br />
* 检查输入的URL地址是否正确<br />
* 输入:str  字符串<br />
*  返 回:true 或 flase; true表示格式正确<br />
*/<br />
function checkURL(str){<br />
if (str.match(/(http[s]?|ftp):\/\/[^\/\.]+?\..+\w$/i) == null) {<br />
return false<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**<br />
* 检查输入的字符是否具有特殊字符<br />
* 输入:str  字符串<br />
* 返 回:true 或 flase; true表示包含特殊字符<br />
* 主要用于注册信息的时候验证<br />
*/<br />
function checkQuote(str){<br />
var items = new Array(&#8220;~&#8221;, &#8220;`&#8221;, &#8220;!&#8221;, &#8220;@&#8221;, &#8220;#&#8221;, &#8220;$&#8221;, &#8220;%&#8221;, &#8220;^&#8221;, &#8220;&amp;&#8221;, &#8220;*&#8221;, &#8220;{&#8220;, &#8220;}&#8221;, &#8220;[", "]&#8220;, &#8220;(&#8220;, &#8220;)&#8221;);<br />
items.push(&#8220;:&#8221;, &#8220;;&#8221;, &#8220;&#8216;&#8221;, &#8220;|&#8221;, &#8220;\\&#8221;, &#8220;&lt;&#8221;, &#8220;&gt;&#8221;, &#8220;?&#8221;, &#8220;/&#8221;, &#8220;&lt;&lt;&#8221;, &#8220;&gt;&gt;&#8221;, &#8220;||&#8221;, &#8220;//&#8221;);<br />
items.push(&#8220;admin&#8221;, &#8220;administrators&#8221;, &#8220;administrator&#8221;, &#8220;管 理员&#8221;, &#8220;系统管理员&#8221;);<br />
items.push(&#8220;select&#8221;, &#8220;delete&#8221;, &#8220;update&#8221;, &#8220;insert&#8221;, &#8220;create&#8221;, &#8220;drop&#8221;, &#8220;alter&#8221;, &#8220;trancate&#8221;);<br />
str = str.toLowerCase();<br />
for (var i = 0; i &lt; items.length; i++) {<br />
if (str.indexOf(items[i]) &gt;= 0) {<br />
return true;<br />
}<br />
}<br />
return false;<br />
}</p>
<p>/**************************************************************************************/<br />
/*************************************时间的验 证*****************************************/<br />
/**************************************************************************************/</p>
<p>/**<br />
* 检查日期格式是否正确<br />
* 输入:str  字符串<br />
* 返 回:true 或 flase; true表示格式正确<br />
* 注意：此处不能验证中文日期格式<br />
* 验证短日期（2007-06-05）<br />
*/<br />
function checkDate(str){<br />
//var value=str.match(/((^((1[8-9]\d{2})|([2-9]\d{3}))(-)(10|12|0?[13578])(-)(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))(-)(11|0?[469])(-)(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))(-)(0?2)(-)(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)(-)(0?2)(-)(29)$)|(^([3579][26]00)(-)(0?2)(-)(29)$)|(^([1][89][0][48])(-)(0?2)(-)(29)$)|(^([2-9][0-9][0][48])(-)(0?2)(-)(29)$)|(^([1][89][2468][048])(-)(0?2)(-)(29)$)|(^([2-9][0-9][2468][048])(-)(0?2)(-)(29)$)|(^([1][89][13579][26])(-)(0?2)(-)(29)$)|(^([2-9][0-9][13579][26])(-)(0?2)(-)(29)$))/);<br />
var value = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);<br />
if (value == null) {<br />
return false;<br />
}<br />
else {<br />
var date = new Date(value[1], value[3] &#8211; 1, value[4]);<br />
return (date.getFullYear() == value[1] &amp;&amp; (date.getMonth() + 1) == value[3] &amp;&amp; date.getDate() == value[4]);<br />
}<br />
}</p>
<p>/**<br />
* 检查时间格式是否正确<br />
* 输入:str  字符串<br />
* 返回:true 或 flase; true表示 格式正确<br />
* 验证时间(10:57:10)<br />
*/<br />
function checkTime(str){<br />
var value = str.match(/^(\d{1,2})(:)?(\d{1,2})\2(\d{1,2})$/)<br />
if (value == null) {<br />
return false;<br />
}<br />
else {<br />
if (value[1] &gt; 24 || value[3] &gt; 60 || value[4] &gt; 60) {<br />
return false<br />
}<br />
else {<br />
return true;<br />
}<br />
}<br />
}</p>
<p>/**<br />
* 检查全日期时间格式是否正确<br />
* 输入:str  字符串<br />
* 返 回:true 或 flase; true表示格式正确<br />
* (2007-06-05 10:57:10)<br />
*/<br />
function checkFullTime(str){<br />
//var value = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/);<br />
var value = str.match(/^(?:19|20)[0-9][0-9]-(?:(?:0[1-9])|(?:1[0-2]))-(?:(?:[0-2][1-9])|(?:[1-3][0-1])) (?:(?:[0-2][0-3])|(?:[0-1][0-9])):[0-5][0-9]:[0-5][0-9]$/);<br />
if (value == null) {<br />
return false;<br />
}<br />
else {<br />
//var date = new Date(checkFullTime[1], checkFullTime[3] &#8211; 1, checkFullTime[4], checkFullTime[5], checkFullTime[6], checkFullTime[7]);<br />
//return (date.getFullYear() == value[1] &amp;&amp; (date.getMonth() + 1) == value[3] &amp;&amp; date.getDate() == value[4] &amp;&amp; date.getHours() == value[5] &amp;&amp; date.getMinutes() == value[6] &amp;&amp; date.getSeconds() == value[7]);<br />
return true;<br />
}</p>
<p>}</p>
<p>/**************************************************************************************/<br />
/************************************身份证号码的 验证*************************************/<br />
/**************************************************************************************/</p>
<p>/**<br />
* 身份证15位编码规则：dddddd yymmdd xx p<br />
* dddddd： 地区码<br />
* yymmdd: 出生年月日<br />
* xx: 顺序类编码，无法确定<br />
* p: 性别，奇数为男，偶数为女<br />
* &lt;p /&gt;<br />
* 身 份证18位编码规则：dddddd yyyymmdd xxx y<br />
* dddddd：地区码<br />
* yyyymmdd: 出生年月日<br />
* xxx: 顺序类编码，无法确定，奇数为男，偶数为女<br />
* y: 校验码，该位数值可通过前17位计算获得<br />
* &lt;p /&gt;<br />
* 18 位号码加权因子为(从右到 左) Wi = [ 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2,1 ]<br />
* 验 证位 Y = [ 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2 ]<br />
* 校验位计算公 式：Y_P = mod( ∑(Ai×Wi),11 )<br />
* i为身份证号码从右往左数的 2&#8230;18 位; Y_P为脚丫校验码所在校验码数 组位置<br />
*<br />
*/<br />
var Wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1];// 加权因子<br />
var ValideCode = [1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2];// 身份证验证位值.10代表X<br />
function IdCardValidate(idCard){<br />
idCard = trim(idCard.replace(/ /g, &#8220;&#8221;));<br />
if (idCard.length == 15) {<br />
return isValidityBrithBy15IdCard(idCard);<br />
}<br />
else<br />
if (idCard.length == 18) {<br />
var a_idCard = idCard.split(&#8220;&#8221;);// 得到身份证数组<br />
if (isValidityBrithBy18IdCard(idCard) &amp;&amp; isTrueValidateCodeBy18IdCard(a_idCard)) {<br />
return true;<br />
}<br />
else {<br />
return false;<br />
}<br />
}<br />
else {<br />
return false;<br />
}<br />
}</p>
<p>/**<br />
* 判断身份证号码为18位时最后的验证位是否正确<br />
* @param a_idCard 身份证号码数组<br />
* @return<br />
*/<br />
function isTrueValidateCodeBy18IdCard(a_idCard){<br />
var sum = 0; // 声明加权求和变量<br />
if (a_idCard[17].toLowerCase() == &#8216;x&#8217;) {<br />
a_idCard[17] = 10;// 将最后位为x的验证码替换为10方便后续操作<br />
}<br />
for (var i = 0; i &lt; 17; i++) {<br />
sum += Wi[i] * a_idCard[i];// 加权求和<br />
}<br />
valCodePosition = sum % 11;// 得到验证码所位置<br />
if (a_idCard[17] == ValideCode[valCodePosition]) {<br />
return true;<br />
}<br />
else {<br />
return false;<br />
}<br />
}</p>
<p>/**<br />
* 通过身份证判断是男是女<br />
* @param idCard 15/18位身份证号码<br />
* @return &#8216;female&#8217;- 女、&#8217;male&#8217;-男<br />
*/<br />
function maleOrFemalByIdCard(idCard){<br />
idCard = trim(idCard.replace(/ /g, &#8220;&#8221;));// 对身份证号码做处理。包括字符间有空格。<br />
if (idCard.length == 15) {<br />
if (idCard.substring(14, 15) % 2 == 0) {<br />
return &#8216;female&#8217;;<br />
}<br />
else {<br />
return &#8216;male&#8217;;<br />
}<br />
}<br />
else<br />
if (idCard.length == 18) {<br />
if (idCard.substring(14, 17) % 2 == 0) {<br />
return &#8216;female&#8217;;<br />
}<br />
else {<br />
return &#8216;male&#8217;;<br />
}<br />
}<br />
else {<br />
return null;<br />
}<br />
}</p>
<p>/**<br />
* 验证18位数身份证号码中的生日是否是有效生日<br />
* @param idCard 18位书身份证字符串<br />
* @return<br />
*/<br />
function isValidityBrithBy18IdCard(idCard18){<br />
var year = idCard18.substring(6, 10);<br />
var month = idCard18.substring(10, 12);<br />
var day = idCard18.substring(12, 14);<br />
var temp_date = new Date(year, parseFloat(month) &#8211; 1, parseFloat(day));<br />
// 这里用getFullYear()获取年份，避免千年虫问题<br />
if (temp_date.getFullYear() != parseFloat(year) ||<br />
temp_date.getMonth() != parseFloat(month) &#8211; 1 ||<br />
temp_date.getDate() != parseFloat(day)) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>/**<br />
* 验证15位数身份证号码中的生日是否是有效生日<br />
* @param idCard15 15位书身份证字符串<br />
* @return<br />
*/<br />
function isValidityBrithBy15IdCard(idCard15){<br />
var year = idCard15.substring(6, 8);<br />
var month = idCard15.substring(8, 10);<br />
var day = idCard15.substring(10, 12);<br />
var temp_date = new Date(year, parseFloat(month) &#8211; 1, parseFloat(day));<br />
// 对于老身份证中的你年龄则不需考虑千年虫问题而使用getYear()方法<br />
if (temp_date.getYear() != parseFloat(year) ||<br />
temp_date.getMonth() != parseFloat(month) &#8211; 1 ||<br />
temp_date.getDate() != parseFloat(day)) {<br />
return false;<br />
}<br />
else {<br />
return true;<br />
}<br />
}</p>
<p>//去掉字符串头尾空格<br />
function trim(str){<br />
return str.replace(/(^\s*)|(\s*$)/g, &#8220;&#8221;);<br />
}</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/13/4521/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/13/4521/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/13/4521/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/13/4521/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/13/4521/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/" title="JavaScript" rel="tag nofollow">JavaScript</a>, <a href="http://www.iwanna.cn/tags/javascript/" title="JavaScript" rel="tag nofollow">JavaScript</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2009/04/29/894/" title="页面输出时一些常用的小技巧 (2009年04月29日)">页面输出时一些常用的小技巧</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/03/31/79/" title="表单元素：40个CSS/JS风格和功能技术处理 (2009年03月31日)">表单元素：40个CSS/JS风格和功能技术处理</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/06/4383/" title="网页打开新窗口的解决方案,拒绝屏蔽 (2010年07月6日)">网页打开新窗口的解决方案,拒绝屏蔽</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/04/29/2874/" title="相见恨晚的一些 JavaScript 技巧 (2010年04月29日)">相见恨晚的一些 JavaScript 技巧</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/09/18/2252/" title="用JS制作的网页版NES模拟器 IE8直接出局 (2009年09月18日)">用JS制作的网页版NES模拟器 IE8直接出局</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/03/31/77/" title="用css+js控制图片大小的方法 (2009年03月31日)">用css+js控制图片大小的方法</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/02/17/2516/" title="有关 JavaScript 的 10 件让人费解的事情 (2010年02月17日)">有关 JavaScript 的 10 件让人费解的事情</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/11/29/2396/" title="新 API 寻求让 JavaScript 操作本地文件 (2009年11月29日)">新 API 寻求让 JavaScript 操作本地文件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/17/1085/" title="并发下载javascript (2009年05月17日)">并发下载javascript</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/24/3340/" title="如何用 JavaScript 检测 IE8 浏览器的文档版本 (2010年05月24日)">如何用 JavaScript 检测 IE8 浏览器的文档版本</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/13/4521/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>推荐9个jquery手风琴菜单插件</title>
		<link>http://www.iwanna.cn/archives/2010/07/13/4506/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/13/4506/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 13:10:10 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Menu]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4506</guid>
		<description><![CDATA[1、jQuery   UI accordion

jqueryUI包中手风琴菜单，堪称经典，优势在于多样化的皮肤。
2、initMen3.1 

非常简单的一个jquery手风琴菜单插件，缺点是样式有点丑。

3、 Making Accordion Menu Using jQuery

你可以控制采用何种事件改变菜单内容，同时增加了菜单上图标的变化。
4、jQuery  Accordion Menu

5、 jQuery – Horizontal Accordion

横向手风琴菜单，这个插件明河要推荐下，很完整的API。
6、 jQuery Examples – Horizontal Accordion

简单的横向手风琴效果。
7、Regular and Hover  Accordion Menus

8、 Slide Out and Drawer Effect

9、 Javascript Accordion Menu Wizard 

类似RIA之家的导航区域的效果，有趣的是作者还提供了几个flash菜单，有兴趣的朋友可以看下。

© 我想网 Akon 所有 , 2010. &#124;
永久链接 &#124;
没有评论 &#124;
提交到
Google Reader
鲜果
抓虾


	标签：JQuery, JQuery, Menu, Menu

	您可能会感兴趣的其他文章
	
	用jQuery和CSS构建下拉菜单 
	一个基于JQuery 和CSS3的滑动菜单 
	网站导航设计的6大分类 
	简单的JQuery聚光灯效果教程 
	推荐8个独特应用的JQuery拖放插件 [...]]]></description>
			<content:encoded><![CDATA[<h4>1、<a href="http://jqueryui.com/demos/accordion/" target="_blank">jQuery   UI accordion</a></h4>
<p><img title="jQuery UI Demo" src="http://images.uheed.com/iwanna/2010/07/13/jquery-accordion-menus/jQuery-UI-Demo.png" alt="" width="538" height="285" /></p>
<p>jqueryUI包中手风琴菜单，堪称经典，优势在于多样化的皮肤。</p>
<h4><a href="http://www.i-marco.nl/weblog/jquery-accordion-3/" target="_blank">2、initMen3.1 </a></h4>
<p><img title="initMen3.1" src="http://images.uheed.com/iwanna/2010/07/13/jquery-accordion-menus/initMen3.1.png" alt="" width="229" height="301" /></p>
<p>非常简单的一个<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>手风琴菜单插件，缺点是样式有点丑。<br />
<span id="more-4506"></span></p>
<h4><a href="http://roshanbh.com.np/2008/06/accordion-menu-using-jquery.html" target="_blank">3、 Making Accordion Menu Using jQuery</a></h4>
<p><img title="accordion-menu-using-jquery" src="http://images.uheed.com/iwanna/2010/07/13/jquery-accordion-menus/accordion-menu-using-jquery.png" alt="" width="159" height="135" /><br />
你可以控制采用何种事件改变菜单内容，同时增加了菜单上图标的变化。</p>
<h4><a href="http://www.lateralcode.com/jquery-accordion-menu/" target="_blank">4、jQuery  Accordion Menu</a></h4>
<p><img title="accordion-menu" src="http://images.uheed.com/iwanna/2010/07/13/jquery-accordion-menus/accordion-menu.png" alt="" width="278" height="315" /></p>
<h4><a href="http://www.portalzine.de/index?/Horizontal_Accordion--print" target="_blank">5、 jQuery – Horizontal Accordion</a></h4>
<p><img title="Horizontal_Accordion_Plugin_2" src="http://images.uheed.com/iwanna/2010/07/13/jquery-accordion-menus/Horizontal_Accordion_Plugin_2-600x169.png" alt="" width="450" height="126" /><br />
横向手风琴菜单，这个插件明河要推荐下，很完整的API。</p>
<h4><a href="http://designreviver.com/tutorials/jquery-examples-horizontal-accordion/" target="_blank">6、 jQuery Examples – Horizontal Accordion</a></h4>
<p><img title="jquery-examples-horizontal-accordion" src="http://images.uheed.com/iwanna/2010/07/13/jquery-accordion-menus/jquery-examples-horizontal-accordion.png" alt="" width="455" height="131" /><br />
简单的横向手风琴效果。</p>
<h4><a href="http://berndmatzner.de/jquery/hoveraccordion/" target="_blank">7、Regular and Hover  Accordion Menus</a></h4>
<p><img title="hoveraccordion" src="http://images.uheed.com/iwanna/2010/07/13/jquery-accordion-menus/hoveraccordion.png" alt="" width="230" height="286" /></p>
<h4><a href="http://jqueryfordesigners.com/slide-out-and-drawer-effect/" target="_blank">8、 Slide Out and Drawer Effect</a></h4>
<p><img title="slide-example" src="http://images.uheed.com/iwanna/2010/07/13/jquery-accordion-menus/slide-example.jpg" alt="" width="283" height="127" /></p>
<h4><a href="http://www.scriptocean.com/accordion.html" target="_blank">9、 Javascript Accordion Menu Wizard </a></h4>
<p><img title="javascript-menu-wizard-jquery-accordion-menus-resources-tutorials-examples" src="http://images.uheed.com/iwanna/2010/07/13/jquery-accordion-menus/javascript-menu-wizard-jquery-accordion-menus-resources-tutorials-examples.jpg" alt="" width="570" height="350" /><br />
类似RIA之家的导航区域的效果，有趣的是作者还提供了几个flash菜单，有兴趣的朋友可以看下。</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/13/4506/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/13/4506/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/13/4506/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/13/4506/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/13/4506/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/topics/ui/menu/" title="Menu" rel="tag nofollow">Menu</a>, <a href="http://www.iwanna.cn/tags/menu/" title="Menu" rel="tag nofollow">Menu</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/27/4767/" title="一个基于JQuery 和CSS3的滑动菜单 (2010年07月27日)">一个基于JQuery 和CSS3的滑动菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/12/4484/" title="网站导航设计的6大分类 (2010年07月12日)">网站导航设计的6大分类</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/11/4460/" title="推荐8个独特应用的JQuery拖放插件 (2010年07月11日)">推荐8个独特应用的JQuery拖放插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4797/" title="实用jquery代码片段集合[下] (2010年07月29日)">实用jquery代码片段集合[下]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/29/4795/" title="实用jquery代码片段集合[上] (2010年07月29日)">实用jquery代码片段集合[上]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/23/1864/" title="如何为您的博客图片添加水印效果？ (2009年06月23日)">如何为您的博客图片添加水印效果？</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/03/29/2605/" title="基于jQuery的新闻图片 (2010年03月29日)">基于jQuery的新闻图片</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/17/4583/" title="制作jquery文字提示插件 (2010年07月17日)">制作jquery文字提示插件</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/13/4506/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax跨域访问解决方案</title>
		<link>http://www.iwanna.cn/archives/2010/07/12/4478/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/12/4478/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 13:54:07 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4478</guid>
		<description><![CDATA[ajax本身实际上是通过XMLHttpRequest对象来进行数据的交互，而浏览器出于安全考虑，不允许js代码进行跨域操作，所以就诞生了很 多跨域的解决方案。当本域和子域间进行访问时最简单的就是设置document.domain，当不同域的访问，大概有下列方法：
1.web端代理的方式，即用户访问A网站时所产生的对B网站的跨域访问请求均提交到A网站的指定页面，由该页 面代替用户页面完成交互，从而返回合适的结果。
2.iframe，解决方案就是用window.location对象的hash属性，利用JS改变hash值 网页不会刷新，可以这样实现通过JS访问hash值来做到通信，大体就是AB网站各嵌入一个对方网站的iframe，然后通过连续不断的监听hash值的 变化来进行通信。比如A网站通过改变B网站iframe的hash后，B网站监听到hash的变化后就进行处理，这种方式需要开发者可以控制两个网站的代 码。

3.通过script标签来请求，原理就是在本域内的A内生成一个JS标签，它的SRC指向请求的另外一个域的 某个页面B，这个src里面通常会加一个A页面定义好的回调函数，B返回数据即可，可以直接返回调用这个回调函数，这种跨域的通信方式被称为JSONP， 此方案存在的缺陷是， script的src属性完成该调用时采取的方式时get方式，如果请求时传递的字符串过大时，可能会无法正常运行。
4.window.name，window.name是一种解决跨域数据传输的新技术，通过在iframe中加 载一个跨域的HTML文件，并且在HTML文件中设置window.name的值为需要传给接受者的数据，接收者就可以取得到window.name的值 并且返回，比较关键的是同源策略的影响对location的控制不受限制，所以需要加载一个代理的页面来让发送页面读取window.name.
5.使用flash，原理是JavaScript将数据提交给本域下的 Flash，通过 Flash   中转去访问其他域的接口，只需要其他域的根目录下有一个crossdomain.xml文件，文件中设置允许所有域名或允许本域访问即可。
了解更多，请看：
http://www.phpchina.com/html/48/n-33848.html
http://www.sitepen.com/blog/2008/07/22/windowname-transport/
http://www.planabc.net/2008/09/01/window_name_transport/
http://hikejun.com/demo/windowname/demo_windowname.html
http://blog.s135.com/ajaxcdr/

© 我想网 Akon 所有 , 2010. &#124;
永久链接 &#124;
没有评论 &#124;
提交到
Google Reader
鲜果
抓虾


	标签：Ajax, Ajax, JavaScript, JavaScript

	您可能会感兴趣的其他文章
	
	使用框架建立富联网应用 
	XmlHttpRequest的串行异步 
	10个关于Ajax的IT人需要知道的事情 
	10个Google 推动的 AJAX 库 API 
	页面输出时一些常用的小技巧 
	表单元素：40个CSS/JS风格和功能技术处理 
	网页打开新窗口的解决方案,拒绝屏蔽 
	简单的Ajax实例 
	相见恨晚的一些 JavaScript 技巧 
	用JS制作的网页版NES模拟器 IE8直接出局 



Feed enhanced by Better Feed from  Ozh
]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">ajax</a>本身实际上是通过XMLHttpRequest对象来进行数据的交互，而浏览器出于安全考虑，不允许js代码进行跨域操作，所以就诞生了很 多跨域的解决方案。当本域和子域间进行访问时最简单的就是设置<strong>document.domain</strong>，当不同域的访问，大概有下列方法：</p>
<p><strong>1.web端代理的方式，</strong>即用户访问A网站时所产生的对B网站的跨域访问请求均提交到A网站的指定页面，由该页 面代替用户页面完成交互，从而返回合适的结果。</p>
<p><strong>2.iframe，</strong>解决方案就是用window.location对象的hash属性，利用JS改变hash值 网页不会刷新，可以这样实现通过JS访问hash值来做到通信，大体就是AB网站各嵌入一个对方网站的iframe，然后通过连续不断的监听hash值的 变化来进行通信。比如A网站通过改变B网站iframe的hash后，B网站监听到hash的变化后就进行处理，这种方式需要开发者可以控制两个网站的代 码。<br />
<span id="more-4478"></span><br />
<strong>3.通过script标签来请求，</strong>原理就是在本域内的A内生成一个JS标签，它的SRC指向请求的另外一个域的 某个页面B，这个src里面通常会加一个A页面定义好的回调函数，B返回数据即可，可以直接返回调用这个回调函数，这种跨域的通信方式被称为JSONP， 此方案存在的缺陷是， script的src属性完成该调用时采取的方式时get方式，如果请求时传递的字符串过大时，可能会无法正常运行。</p>
<p><strong>4.window.name，</strong>window.name是一种解决跨域数据传输的新技术，通过在iframe中加 载一个跨域的HTML文件，并且在HTML文件中设置window.name的值为需要传给接受者的数据，接收者就可以取得到window.name的值 并且返回，比较关键的是同源策略的影响对location的控制不受限制，所以需要加载一个代理的页面来让发送页面读取window.name.</p>
<p><strong>5.使用flash，</strong>原理是<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a>将数据提交给本域下的 Flash，通过 Flash   中转去访问其他域的接口，只需要其他域的根目录下有一个crossdomain.xml文件，文件中设置允许所有域名或允许本域访问即可。</p>
<p>了解更多，请看：</p>
<p><a href="http://www.phpchina.com/html/48/n-33848.html" target="_blank">http://www.phpchina.com/html/48/n-33848.html</a></p>
<p><a href="http://www.sitepen.com/blog/2008/07/22/windowname-transport/" target="_blank">http://www.sitepen.com/blog/2008/07/22/windowname-transport/</a></p>
<p><a href="http://www.planabc.net/2008/09/01/window_name_transport/" target="_blank">http://www.planabc.net/2008/09/01/window_name_transport/</a></p>
<p><a href="http://hikejun.com/demo/windowname/demo_windowname.html" target="_blank">http://hikejun.com/demo/windowname/demo_windowname.html</a></p>
<p><a href="http://blog.s135.com/ajaxcdr/" target="_blank">http://blog.s135.com/ajaxcdr/</a></p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/12/4478/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/12/4478/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/12/4478/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/12/4478/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/12/4478/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/ajax/" title="Ajax" rel="tag nofollow">Ajax</a>, <a href="http://www.iwanna.cn/tags/ajax/" title="Ajax" rel="tag nofollow">Ajax</a>, <a href="http://www.iwanna.cn/topics/ui/javascript/" title="JavaScript" rel="tag nofollow">JavaScript</a>, <a href="http://www.iwanna.cn/tags/javascript/" title="JavaScript" rel="tag nofollow">JavaScript</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2010/07/27/4752/" title="使用框架建立富联网应用 (2010年07月27日)">使用框架建立富联网应用</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/23/1862/" title="XmlHttpRequest的串行异步 (2009年06月23日)">XmlHttpRequest的串行异步</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/21/1854/" title="10个关于Ajax的IT人需要知道的事情 (2009年06月21日)">10个关于Ajax的IT人需要知道的事情</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/21/3284/" title="10个Google 推动的 AJAX 库 API (2010年05月21日)">10个Google 推动的 AJAX 库 API</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/04/29/894/" title="页面输出时一些常用的小技巧 (2009年04月29日)">页面输出时一些常用的小技巧</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/03/31/79/" title="表单元素：40个CSS/JS风格和功能技术处理 (2009年03月31日)">表单元素：40个CSS/JS风格和功能技术处理</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/06/4383/" title="网页打开新窗口的解决方案,拒绝屏蔽 (2010年07月6日)">网页打开新窗口的解决方案,拒绝屏蔽</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/03/1678/" title="简单的Ajax实例 (2009年06月3日)">简单的Ajax实例</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/04/29/2874/" title="相见恨晚的一些 JavaScript 技巧 (2010年04月29日)">相见恨晚的一些 JavaScript 技巧</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/09/18/2252/" title="用JS制作的网页版NES模拟器 IE8直接出局 (2009年09月18日)">用JS制作的网页版NES模拟器 IE8直接出局</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/12/4478/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>推荐8个独特应用的JQuery拖放插件</title>
		<link>http://www.iwanna.cn/archives/2010/07/11/4460/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/11/4460/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 08:31:34 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4460</guid>
		<description><![CDATA[Web2.0很重要的一个特征就是交互性的强化，而拖放的引入，可以起到很好的交互效果，JQuery  UI包已经包含了拖放，但拖放的应用不只应用于层的拖拉，接下来明河推荐几个独到的应用拖放的JQuery插件。
明河是推荐直接使用jquery UI包中的拖放，当你的需求jquery 拖放UI无法满足时，不妨看下以下插件。
1、Superfun


查看示例
点此下载

示例中演示了对倾斜容器的拖放，当然这个demo不兼容IE。

2、CropZoom


查看示例
点此下载

拖放在图片剪切中的应用，这个朋友么应该不陌生，这个jquery插件的强大之处在于，你不只可以改变剪切区域，还可以控制图片大小，以及图片的旋 转。
3、Jquery Iviewer


查看示例
点此下载

这款jquery插件可当做web地图的基础模型，对web地图有兴趣的朋友很有参考意义。
4、Dragscrollable


查看示例
点此下载

当你在容器内进行拖拉时滚动条也会随之滚动，明河觉得有意思的地方在于标尺。
5、Table  Drag and Drop JQuery plugin


查看示例
点此下载

表格行数据拖放。
6、 jquery  mb.containerPlus


查看示例
点此下载

华丽的弹出窗体拖拉，你可以自由的控制弹出的窗体。
7、Creating  a Draggable Sitemap with JQuery


查看示例

可拖放的站点地图……貌似实际意义不大。
8、jQuery Reel Plugin


查看示例
点此下载

这个插件很有意思，产生类似全景的效果。

© 我想网 Akon 所有 , 2010. &#124;
永久链接 &#124;
没有评论 &#124;
提交到
Google Reader
鲜果
抓虾


	标签：JQuery, JQuery, Plugin

	您可能会感兴趣的其他文章
	
	FCBKcomplete v 2.02 
	6个jQuery图标插件的应用程序 
	50个表单功能，验证，安全和自定义化的jQuery插件 
	30个最好的jQuery表单插件 
	30+ 新鲜惊奇的 jQuery 插件与教程 
	21个演示展示强大的jQuery特效 
	2010年4月：最佳的jQuery插件 
	10+个jQuery图片滚动插件介绍 
	10 个帮助你处理Web页面层布局的jQuery插件 
	简单的JQuery聚光灯效果教程 



Feed enhanced by Better Feed [...]]]></description>
			<content:encoded><![CDATA[<p>Web2.0很重要的一个特征就是交互性的强化，而拖放的引入，可以起到很好的交互效果，<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">JQuery</a>  UI包已经包含了拖放，但拖放的应用不只应用于层的拖拉，接下来明河推荐几个独到的应用<strong><a title="推荐8个独特应用的JQuery拖放插件" href="http://www.iwanna.cn/archives/2010/07/11/4460/">拖放的JQuery插件</a></strong>。</p>
<p>明河是推荐直接使用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a> UI包中的拖放，当你的需求<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a> 拖放UI无法满足时，不妨看下以下插件。</p>
<h4>1、<a href="http://www.fokistudios.com/superfun/" target="_blank">Superfun</a></h4>
<p><a href="http://www.iwanna.cn/" title="我想网" target="_blank"><img title="superfun-drag-drop-plugins" src="http://images.uheed.com/iwanna/2010/07/11/jquery-drag-plugin/superfun-drag-drop-plugins-461x400.jpg" alt="" width="450" height="390" /></a></p>
<ul class="tow-columns clearfix">
<li class="l"><a target="_blank" class="btn-view-demo" href="http://www.fokistudios.com/superfun/">查看示例</a></li>
<li class="l"><a href="http://www.fokistudios.com/superfun/SuperFun-0.16.zip" title=" " class="btn-download">点此下载</a></li>
</ul>
<p>示例中演示了对倾斜容器的拖放，当然这个demo不兼容IE。<br />
<span id="more-4460"></span></p>
<h4>2、<a href="http://www.cropzoom.com.ar/index.html">CropZoom</a></h4>
<p><a href="http://www.iwanna.cn/" title="我想网" target="_blank"><img title="cropzoom-drag-drop-plugins" src="http://images.uheed.com/iwanna/2010/07/11/jquery-drag-plugin/cropzoom-drag-drop-plugins.jpg" alt="" width="570" height="242" /></a></p>
<ul class="tow-columns clearfix">
<li class="l"><a target="_blank" class="btn-view-demo" href="http://www.cropzoom.com.ar/index.html">查看示例</a></li>
<li class="l"><a href="http://www.cropzoom.com.ar/download.html" title=" " class="btn-download">点此下载</a></li>
</ul>
<p>拖放在图片剪切中的应用，这个朋友么应该不陌生，这个<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>插件的强大之处在于，你不只可以改变剪切区域，还可以控制图片大小，以及图片的旋 转。</p>
<h4>3、<a href="http://wiki.github.com/can3p/iviewer/">Jquery Iviewer</a></h4>
<p><a href="http://www.iwanna.cn/" title="我想网" target="_blank"><img title="iviewer-drag-drop-plugins" src="http://images.uheed.com/iwanna/2010/07/11/jquery-drag-plugin/iviewer-drag-drop-plugins-497x400.jpg" alt="" width="450" height="362" /></a></p>
<ul class="tow-columns clearfix">
<li class="l"><a target="_blank" class="btn-view-demo" href="http://test.dpetroff.ru/jquery.iviewer/test/">查看示例</a></li>
<li class="l"><a href="http://plugins.jquery.com/files/jquery.iviewer-0.4.3.zip" title=" " class="btn-download">点此下载</a></li>
</ul>
<p>这款<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>插件可当做web地图的基础模型，对web地图有兴趣的朋友很有参考意义。</p>
<h4>4、<a href="http://plugins.jquery.com/project/Dragscrollable">Dragscrollable</a></h4>
<p><a href="http://www.iwanna.cn/" title="我想网" target="_blank"><img title="Dragscrollable-drag-drop-plugins" src="http://images.uheed.com/iwanna/2010/07/11/jquery-drag-plugin/Dragscrollable-drag-drop-plugins-455x400.jpg" alt="" width="450" height="395" /></a></p>
<ul class="tow-columns clearfix">
<li class="l"><a target="_blank" class="btn-view-demo" href="http://hitconsultants.com/dragscroll_scrollsync/scrollpane.html">查看示例</a></li>
<li class="l"><a href="http://plugins.jquery.com/files/dragscrollable.js.txt" title=" " class="btn-download">点此下载</a></li>
</ul>
<p>当你在容器内进行拖拉时滚动条也会随之滚动，明河觉得有意思的地方在于标尺。</p>
<h4>5、<a href="http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/">Table  Drag and Drop JQuery plugin</a></h4>
<p><a href="http://www.iwanna.cn/" title="我想网" target="_blank"><img title="drag-and-drop-drag-drop-plugins" src="http://images.uheed.com/iwanna/2010/07/11/jquery-drag-plugin/drag-and-drop-drag-drop-plugins.jpg" alt="" width="270" height="368" /></a></p>
<ul class="tow-columns clearfix">
<li class="l"><a target="_blank" class="btn-view-demo" href="http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/">查看示例</a></li>
<li class="l"><a href="http://www.isocra.com/articles/jquery.tablednd_0_5.js.zip" title=" " class="btn-download">点此下载</a></li>
</ul>
<p>表格行数据拖放。</p>
<h4>6、 <a href="http://pupunzi.open-lab.com/mb-jquery-components/mb-containerplus/">jquery  mb.containerPlus</a></h4>
<p><a href="http://www.iwanna.cn/" title="我想网" target="_blank"><img title="containerPlus-drag-drop-plugins" src="http://images.uheed.com/iwanna/2010/07/11/jquery-drag-plugin/containerPlus-drag-drop-plugins-380x400.jpg" alt="" width="380" height="400" /></a></p>
<ul class="tow-columns clearfix">
<li class="l"><a target="_blank" class="btn-view-demo" href="http://pupunzi.com/#mb.components/mb.containerPlus/containerPlus.html">查看示例</a></li>
<li class="l"><a href="http://github.com/downloads/pupunzi/jquery.mb.containerPlus/jquery.mb.containerPlus.2.5.0.zip" title=" " class="btn-download">点此下载</a></li>
</ul>
<p>华丽的弹出窗体拖拉，你可以自由的控制弹出的窗体。</p>
<h4>7、<a href="http://boagworld.com/technology/creating-a-draggable-sitemap-with-jquery">Creating  a Draggable Sitemap with JQuery</a></h4>
<p><a href="http://www.iwanna.cn/" title="我想网" target="_blank"><img title="creating-a-draggable-sitemap-with-jquery-drag-drop-plugins" src="http://images.uheed.com/iwanna/2010/07/11/jquery-drag-plugin/creating-a-draggable-sitemap-with-jquery-drag-drop-plugins.jpg" alt="" width="570" height="362" /></a></p>
<ul class="tow-columns clearfix">
<li class="l"><a target="_blank" class="btn-view-demo" href="http://boagworld.com/demos/sitemap/">查看示例</a></li>
</ul>
<p>可拖放的站点地图……貌似实际意义不大。</p>
<h4>8、<a href="http://jquery.vostrel.cz/reel#demo">jQuery Reel Plugin</a></h4>
<p><a href="http://www.iwanna.cn/" title="我想网" target="_blank"><img title="reel-drag-drop-plugins" src="http://images.uheed.com/iwanna/2010/07/11/jquery-drag-plugin/reel-drag-drop-plugins.jpg" alt="" width="557" height="158" /></a></p>
<ul class="tow-columns clearfix">
<li class="l"><a target="_blank" class="btn-view-demo" href="http://jquery.vostrel.cz/reel#demo">查看示例</a></li>
<li class="l"><a href="http://jquery.vostrel.cz/reel#download" title=" " class="btn-download">点此下载</a></li>
</ul>
<p>这个插件很有意思，产生类似全景的效果。</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/11/4460/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/11/4460/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/11/4460/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/11/4460/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/11/4460/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/plugin/" title="Plugin" rel="tag nofollow">Plugin</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2009/04/23/811/" title="FCBKcomplete v 2.02 (2009年04月23日)">FCBKcomplete v 2.02</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/01/1621/" title="6个jQuery图标插件的应用程序 (2009年06月1日)">6个jQuery图标插件的应用程序</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/08/4164/" title="50个表单功能，验证，安全和自定义化的jQuery插件 (2010年07月8日)">50个表单功能，验证，安全和自定义化的jQuery插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/08/2812/" title="30个最好的jQuery表单插件 (2010年05月8日)">30个最好的jQuery表单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/01/26/2474/" title="30+ 新鲜惊奇的 jQuery 插件与教程 (2010年01月26日)">30+ 新鲜惊奇的 jQuery 插件与教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/23/4691/" title="21个演示展示强大的jQuery特效 (2010年07月23日)">21个演示展示强大的jQuery特效</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/14/2913/" title="2010年4月：最佳的jQuery插件 (2010年05月14日)">2010年4月：最佳的jQuery插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/07/4401/" title="10+个jQuery图片滚动插件介绍 (2010年07月7日)">10+个jQuery图片滚动插件介绍</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/26/3379/" title="10 个帮助你处理Web页面层布局的jQuery插件 (2010年05月26日)">10 个帮助你处理Web页面层布局的jQuery插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/11/4460/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery + CSS3 实现图片圆角</title>
		<link>http://www.iwanna.cn/archives/2010/07/09/4445/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/09/4445/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 12:56:48 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4445</guid>
		<description><![CDATA[目标
目标是用 CSS3 border-radius 和 box-shadow 来实现如下图效果

左手: 圆角+外投影
你的右手旁边是我的左手: 圆角+内投影

问题
问题是这年头木有一档浏览器可以完美的在图片上应用圆角和阴影
webkit 可以显示圆角,但木有内投影
firefox 和内裤被戳破一样还坚挺的直着

CSS 淫技
灰常简单: 在图片外头套一层超薄&#60;span /&#62;然后把原图作为 background-image.
要隐藏原图的话,可以 opacity:0 或 display:none
偶发现 opacity 更淫荡点,因为这么整用户还能图片另存为
当然出于某些阴暗目的或光明磊落隐私考虑,可能会偏向 display

最终用 jQuery 的解决方案
本着怎么偷懒怎么来的原则,我们用 jQuery 来自动给图片套&#60;span /&#62;

不解释, 上代码先
&#60;script type="text/javascript" src="jquery-1.4.2.min.js"&#62;&#60;/script&#62;
&#60;script type="text/javascript"&#62;
$(document).ready(function(){

  $(".rounded-img, .rounded-img2").load(function() {
    $(this).wrap(function(){
      return '&#60;span style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + [...]]]></description>
			<content:encoded><![CDATA[<p><strong>目标</strong></p>
<p>目标是用 CSS3 border-radius 和 box-shadow 来实现如下图效果</p>
<p><img title="sample-rounded-images" src="http://images.uheed.com/iwanna/2010/07/09/sample-rounded-images.gif" alt="" width="470" height="120" /></p>
<p>左手: 圆角+外投影<br />
你的右手旁边是我的左手: 圆角+内投影<br />
<span id="more-4445"></span><br />
<strong>问题</strong><br />
问题是这年头木有一档浏览器可以完美的在图片上应用圆角和阴影<br />
webkit 可以显示圆角,但木有内投影<br />
firefox 和内裤被戳破一样还坚挺的直着</p>
<p><img title="display-problems" src="http://images.uheed.com/iwanna/2010/07/09/display-problems.png" alt="" width="470" height="234" /></p>
<p><strong><a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">CSS</a> 淫技</strong></p>
<p>灰常简单: 在图片外头套一层超薄&lt;span /&gt;然后把原图作为 background-image.<br />
要隐藏原图的话,可以 opacity:0 或 display:none<br />
偶发现 opacity 更淫荡点,因为这么整用户还能图片另存为<br />
当然出于某些阴暗目的或光明磊落隐私考虑,可能会偏向 display</p>
<p><img title="css-background-img-trick" src="http://images.uheed.com/iwanna/2010/07/09/css-background-img-trick.gif" alt="" width="470" height="140" /></p>
<p><strong>最终用 <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> 的解决方案</strong></p>
<p>本着怎么偷懒怎么来的原则,我们用 <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> 来自动给图片套&lt;span /&gt;</p>
<p><img title="jquery-wrap" src="http://images.uheed.com/iwanna/2010/07/09/jquery-wrap.gif" alt="" width="470" height="66" /></p>
<p>不解释, 上代码先</p>
<pre><code>&lt;script type="text/<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">javascript</a>" src="<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>-1.4.2.min.js"&gt;&lt;/script&gt;
&lt;script type="text/<a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">javascript</a>"&gt;
$(document).ready(function(){

  $(".rounded-img, .rounded-img2").load(function() {
    $(this).wrap(function(){
      return '&lt;span style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" /&gt;';
    });
    $(this).<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a>("opacity","0");
  });

});

&lt;/script&gt;

</code></pre>
<p>接下来开始解释<br />
1. 调用 <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> 库<br />
2. ready 就是 DOM 全部加载后再触发的事件, 否则一旦有图片的 DOM 节点后于 JS 加载,就会绑定不到<br />
3. $(&#8220;.rounded-img, .rounded-img2&#8243;) 选中所有 class 名为 rounded-img 和  rounded-img2 的元素<br />
4. 给俩元素集绑定 load 事件 (偶很疑惑为何这么写)<br />
5. 在每个图片外面包含一个 span, 这个 span 的 class 为原元素的 class ,这个 span 的 style 里的  background 取值自原图的 src 值, 宽高同理<br />
6. 给每个图片写个style=&#8221;opacity:0&#8243;</p>
<p><strong>看起来素酱紫滴:</strong></p>
<p><img title="sample-usages" src="http://images.uheed.com/iwanna/2010/07/09/sample-usages.gif" alt="" width="470" height="234" /></p>
<p><strong>大猫的调整</strong></p>
<pre><code>$(function(){
  $(".avatar").wrap(function(){
      return '&lt;span style="background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" /&gt;';
    }).<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a>("opacity","0");
});
</code></pre>
<p><strong>理由:</strong><br />
1. $(document).ready(function(){}) 相当于 $().ready(function(){}) 相当于  $(function(){}) ,貌似有这么一说,嘻嘻<br />
2. class名改为 .avatar 如果你是 wordpress 的评论头像, 都封装好了,要改结构也不是很方便,哈<br />
3. 去掉图片的 .load 事件, 因为如果图片从缓存中获取, 有可能就不会触发这个事件, 反正是 DOM ready,霸王硬上弓了<br />
4. 直接用链式写法点花点月点秋香</p>
<p>然后你得在你的主题 style.<a href="http://www.iwanna.cn/tags/css/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with CSS">css</a> 加上那么几条<br />
因为 webkit 的内阴影配合圆角就是一坨屎,所以我用外阴影了<br />
iPhone 的safari 还不支持 inset 内阴影, 如果有内阴影控, 可以用线性渐变配合RGBA假装是阴影&#8230;</p>
<pre><code>
.avatar {
	display: inline-block;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;
	border-radius: 5px;
	-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
	-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
	box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
</code></pre>
<p><strong>IE 呢?</strong><br />
screw you!</p>
<p>不过目前偶是弄个中间镂空PNG遮罩,多一个请求<br />
要是平滑那还得PNG32<br />
要是PNG32那IE6捏?<br />
IE6用 AlphaImageLoader 滤镜一旦图片加载失败,整个页面就脱光了死给你看</p>
<p>screw IE!</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/09/4445/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/09/4445/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/09/4445/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/09/4445/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/09/4445/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/css/" title="CSS" rel="tag nofollow">CSS</a>, <a href="http://www.iwanna.cn/tags/css/" title="CSS" rel="tag nofollow">CSS</a>, <a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/24/1129/" title="八种布局方案改善你的设计 (2009年05月24日)">八种布局方案改善你的设计</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/27/4767/" title="一个基于JQuery 和CSS3的滑动菜单 (2010年07月27日)">一个基于JQuery 和CSS3的滑动菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/02/4328/" title="CSS3+JQuery实现固定头部的导航菜单 (2010年07月2日)">CSS3+JQuery实现固定头部的导航菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/30/1894/" title="40+ Web前端开发必备的备忘单[上] (2009年06月30日)">40+ Web前端开发必备的备忘单[上]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/04/29/894/" title="页面输出时一些常用的小技巧 (2009年04月29日)">页面输出时一些常用的小技巧</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/07/16/2019/" title="面向对象的CSS (2009年07月16日)">面向对象的CSS</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/07/981/" title="针对IE8正式版的CSS hack (2009年05月7日)">针对IE8正式版的CSS hack</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/01/920/" title="跨浏览器的CSS固定定位{position:fixed} (2009年05月1日)">跨浏览器的CSS固定定位{position:fixed}</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/09/3823/" title="跨浏览器兼容的 CSS 编码准则和技巧 (2010年06月9日)">跨浏览器兼容的 CSS 编码准则和技巧</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/09/4445/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>50个表单功能，验证，安全和自定义化的jQuery插件</title>
		<link>http://www.iwanna.cn/archives/2010/07/08/4164/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/08/4164/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 14:16:17 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Translate]]></category>
		<category><![CDATA[翻译]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4164</guid>
		<description><![CDATA[http://speckyboy.com/2010/06/22/50-jquery-plugins-for-form-functionality-validation-security-and-customisation/
http://www.iwanna.cn/archives/2010/06/23/4164/
说实话，填写表单总是件很痛苦的事。那么对于开发者而言呢？可以创建一份表单说他们而言是件更为痛苦的事。没有人真正会喜欢他们，对于开发者而言，当涉及到表单开发时最困难的挑战并非仅仅在于创建一份简单且快速为用户所接受使用，但也必须是尽可能地方便且使用。这的确是相当的不容易啊。
本篇文章中，我们已经收集了50个JQuery插件以帮助您建立强大的表单。今后如果您碰到任何关于表单的解决方案，想必您会从这里找到您JQuery方案。
表单功能插件
Elastic – Make your  textareas grow
这个jQuery插件让你textareas表单域增长和缩小，以适应它的内容。它的灵感来自于Facebook 的 textareas 域。
Elastic – Make your  textareas grow »

jQuery  “Highlight” Plugin
高亮区可以提高表单的可用性，突出页面上的交互元素。其主要是在表单中使用，但它也可用于表格，列表，或任何您指定的元素。
jQuery  “Highlight” Plugin »
Autotab: jQuery  Auto-Tabbing and Filtering
Autotab是一个jQuery插件，它提供的自动切换和过滤表单域中的文本域。一旦输入的字符串达到了已定义的文本长度，它会自动切换到自动设置的目标元素。
Autotab: jQuery  Auto-Tabbing and Filtering »
Ajax  Fancy Captcha
Ajax  Fancy Captcha通过新页面帮助您保护页面远离机器人及垃圾邮件发送者的攻击，仅仅是通过很“人性化的验证”实现。这是通过将指定项拖拽到一个圆圈中实现的。
Ajax  Fancy Captcha »
jQuery  NobleCount
NobleCount可以动态地将textarea域中剩余字符的数目显示在本文中，Twitter风格。
jQuery  NobleCount »
Password  Strength Indicator and Generator
Password [...]]]></description>
			<content:encoded><![CDATA[<p>http://speckyboy.com/2010/06/22/50-<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>-plugins-for-form-functionality-validation-security-and-customisation/</p>
<p>http://www.iwanna.cn/archives/2010/06/23/4164/</p>
<p>说实话，填写表单总是件很痛苦的事。那么对于开发者而言呢？可以创建一份表单说他们而言是件更为痛苦的事。没有人真正会喜欢他们，对于开发者而言，当涉及到表单开发时最困难的挑战并非仅仅在于创建一份简单且快速为用户所接受使用，但也必须是尽可能地方便且使用。这的确是相当的不容易啊。</p>
<p>本篇文章中，我们已经收集了<strong><a href="http://www.iwanna.cn/archives/2010/06/23/4164/" title="50个表单功能，验证，安全和自定义化的jQuery插件">50个JQuery插件</a></strong>以帮助您建立强大的表单。今后如果您碰到任何关于表单的解决方案，想必您会从这里找到您<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">JQuery</a>方案。</p>
<h1>表单功能插件</h1>
<h2><a href="http://www.unwrongest.com/projects/elastic/" target="_blank">Elastic – Make your  textareas grow</a></h2>
<p><a href="http://www.unwrongest.com/projects/elastic/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_01.jpg" alt="Elastic – Make your textareas grow - jQuery Form Plugin" width="320" height="226" /></a>这个<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>插件让你textareas表单域增长和缩小，以适应它的内容。它的灵感来自于Facebook 的 textareas 域。<br />
<a href="http://www.unwrongest.com/projects/elastic/" target="_blank">Elastic – Make your  textareas grow »</a><br />
<span id="more-4164"></span></p>
<h2><a href="http://www.keyframesandcode.com/code/development/javascript/jquery-highlight-plugin/" target="_blank">jQuery  “Highlight” Plugin</a></h2>
<p><a href="http://www.keyframesandcode.com/code/development/javascript/jquery-highlight-plugin/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_02.jpg" alt="jQuery “Highlight” Plugin - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.keyframesandcode.com/code/development/javascript/jquery-highlight-plugin/" target="_blank">高亮区</a>可以提高表单的可用性，突出页面上的交互元素。其主要是在表单中使用，但它也可用于表格，列表，或任何您指定的元素。<br />
<a href="http://www.keyframesandcode.com/code/development/javascript/jquery-highlight-plugin/" target="_blank">jQuery  “Highlight” Plugin »</a></p>
<h2><a href="http://www.lousyllama.com/sandbox/jquery-autotab" target="_blank">Autotab: jQuery  Auto-Tabbing and Filtering</a></h2>
<p><a href="http://www.lousyllama.com/sandbox/jquery-autotab" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_03.jpg" alt="Autotab: jQuery Auto-Tabbing and Filtering - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.lousyllama.com/sandbox/jquery-autotab" target="_blank">Autotab</a>是一个<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>插件，它提供的自动切换和过滤表单域中的文本域。一旦输入的字符串达到了已定义的文本长度，它会自动切换到自动设置的目标元素。<br />
<a href="http://www.lousyllama.com/sandbox/jquery-autotab" target="_blank">Autotab: jQuery  Auto-Tabbing and Filtering »</a></p>
<h2><a href="http://www.webdesignbeach.com/beachbar/ajax-fancy-captcha-jquery-plugin" target="_blank">Ajax  Fancy Captcha</a></h2>
<p><a href="http://www.webdesignbeach.com/beachbar/ajax-fancy-captcha-jquery-plugin" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_04.jpg" alt="Ajax Fancy Captcha - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.webdesignbeach.com/beachbar/ajax-fancy-captcha-jquery-plugin" target="_blank">Ajax  Fancy Captcha</a>通过新页面帮助您保护页面远离机器人及垃圾邮件发送者的攻击，仅仅是通过很“人性化的验证”实现。这是通过将指定项拖拽到一个圆圈中实现的。<br />
<a href="http://www.webdesignbeach.com/beachbar/ajax-fancy-captcha-jquery-plugin" target="_blank">Ajax  Fancy Captcha »</a></p>
<h2><a href="http://tpgblog.com/2010/03/23/noblecount-jquery-character-count-plugin/" target="_blank">jQuery  NobleCount</a></h2>
<p><a href="http://tpgblog.com/2010/03/23/noblecount-jquery-character-count-plugin/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_05.jpg" alt="jQuery NobleCount - jQuery Form Plugin" width="320" height="226" /></a><a href="http://tpgblog.com/2010/03/23/noblecount-jquery-character-count-plugin/" target="_blank">NobleCount</a>可以动态地将textarea域中剩余字符的数目显示在本文中，Twitter风格。<br />
<a href="http://tpgblog.com/2010/03/23/noblecount-jquery-character-count-plugin/" target="_blank">jQuery  NobleCount »</a></p>
<h2><a href="http://benjaminsterling.com/password-strength-indicator-and-generator/" target="_blank">Password  Strength Indicator and Generator</a></h2>
<p><a href="http://benjaminsterling.com/password-strength-indicator-and-generator/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_06.jpg" alt="Password Strength Indicator and Generator - jQuery Form Plugin" width="320" height="226" /></a><a href="http://benjaminsterling.com/password-strength-indicator-and-generator/" target="_blank">Password  Strength Indicator and Generator</a> 插件允许您设置元素的类，这样您就可以图形化显示密码的强度。<br />
<a href="http://benjaminsterling.com/password-strength-indicator-and-generator/" target="_blank">Password  Strength Indicator and Generator »</a></p>
<h2><a href="http://www.jankoatwarpspeed.com/post/2009/09/28/webform-wizard-jquery.aspx" target="_blank">FormToWizard  Plugin</a></h2>
<p><a href="http://www.jankoatwarpspeed.com/post/2009/09/28/webform-wizard-jquery.aspx" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_07.jpg" alt="FormToWizard Plugin - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.jankoatwarpspeed.com/post/2009/09/28/webform-wizard-jquery.aspx" target="_blank">FormToWizard</a> 插件允许您以“依次向左”的步骤实现表单信息提交。<br />
<a href="http://www.jankoatwarpspeed.com/post/2009/09/28/webform-wizard-jquery.aspx" target="_blank">FormToWizard  Plugin »</a></p>
<h2><a href="http://www.csskarma.com/blog/sliding-labels-v2/" target="_blank">Sliding Labels –  jQuery Form Plugin</a></h2>
<p><a href="http://www.csskarma.com/blog/sliding-labels-v2/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_08.jpg" alt="Sliding Labels - jQuery Form Plugin" width="320" height="226" /></a><br />
<a href="http://www.csskarma.com/blog/sliding-labels-v2/" target="_blank">Sliding Labels –  jQuery Form Plugin »</a></p>
<h2><a href="http://jquery.kuzemchak.net/toggleval.php" target="_blank">ToggleVal</a></h2>
<p><a href="http://jquery.kuzemchak.net/toggleval.php" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_09.jpg" alt="ToggleVal - jQuery Form Plugin" width="320" height="226" /></a><a href="http://jquery.kuzemchak.net/toggleval.php" target="_blank">ToggleVal</a>会让您选择以不同的方式来填充表单文本字段（某些不同的方式），当接收和失去焦点的时候会自动切换至默认值。<br />
<a href="http://jquery.kuzemchak.net/toggleval.php" target="_blank">ToggleVal »</a></p>
<h2><a href="http://itgroup.com.ph/alphanumeric/" target="_blank">jQuery  AlphaNumeric</a></h2>
<p><a href="http://itgroup.com.ph/alphanumeric/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_10.jpg" alt="jQuery AlphaNumeric - jQuery Form Plugin" width="320" height="226" /></a><a href="http://itgroup.com.ph/alphanumeric/" target="_blank">jQuery  AlphaNumeric</a> is a <a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">javascript</a> control plugin that allows you to limit  what characters a user can enter on textboxes or textareas.<br />
<a href="http://itgroup.com.ph/alphanumeric/" target="_blank">jQuery  AlphaNumeric »</a></p>
<h1>Form Encyription and Password  Security</h1>
<h2><a href="http://www.dreamcss.com/2009/08/javascript-html-form-encryption-plugin.html" target="_blank">jCryption</a></h2>
<p><a href="http://www.dreamcss.com/2009/08/javascript-html-form-encryption-plugin.html" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_11.jpg" alt="jCryption - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.dreamcss.com/2009/08/javascript-html-form-encryption-plugin.html" target="_blank">jCryption</a> is a <a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">JavaScript</a> HTML-Form encryption plugin, which encrypts the  POST/GET data submitted by forms.<br />
Normally, when you submit a form,  data will be sent in plain text if no SSL is used. But SSL is not  supported by every webhost nor it’s easy to install/apply at times. So  in this situation the jCryption plugin helps you to encrypt your data  with ease.<br />
<a href="http://www.dreamcss.com/2009/08/javascript-html-form-encryption-plugin.html" target="_blank">jCryption  »</a></p>
<h2><a href="http://bassistance.de/jquery-plugins/jquery-plugin-password-validation/" target="_blank">Password  Validation Plugin</a></h2>
<p><a href="http://bassistance.de/jquery-plugins/jquery-plugin-password-validation/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_12.jpg" alt="Password Validation Plugin - jQuery Form Plugin" width="320" height="226" /></a>This plugin offers a function that rates passwords for  factors like mixed upper/lower case, mix of characters (digits, special  characters), length and similarity to a username (optional) and gives a  custom method for the validation plugin that uses the rating function to  display a password strength meter, requiring the field to have a “good”  rating.<br />
<a href="http://bassistance.de/jquery-plugins/jquery-plugin-password-validation/" target="_blank">Password  Validation Plugin »</a></p>
<h2><a href="http://www.unwrongest.com/projects/password-strength/" target="_blank">Password  Strength – Estimates brute force time</a></h2>
<p><a href="http://www.unwrongest.com/projects/password-strength/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_13.jpg" alt="Password Strength – Estimates brute force time - jQuery Form  Plugin" width="320" height="226" /></a><a href="http://www.unwrongest.com/projects/password-strength/" target="_blank">Password  Strength</a> tries to calculate how many possibilities the hacker needs  to try to guess your password. It makes the assumption that it is  possible to test 2800 million passwords per second.<br />
<a href="http://www.unwrongest.com/projects/password-strength/" target="_blank">Password  Strength »</a></p>
<h2><a href="http://phiras.wordpress.com/2009/07/29/password-strength-meter-v-2/" target="_blank">Password  Strength Meter v2</a></h2>
<p><a href="http://phiras.wordpress.com/2009/07/29/password-strength-meter-v-2/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_14.jpg" alt="Password Strength Meter v2 - jQuery Form Plugin" width="320" height="226" /></a>The <a href="http://phiras.wordpress.com/2009/07/29/password-strength-meter-v-2/" target="_blank">Password  Strength Meter</a> works by presenting a global variable score and at  the end of the algorithm the plugin will decide the passwords strength  according to the score value.<br />
<a href="http://phiras.wordpress.com/2009/07/29/password-strength-meter-v-2/" target="_blank">Password  Strength Meter v2 »</a></p>
<h1>Form Mask Plugin</h1>
<h2><a href="http://digitalbush.com/projects/masked-input-plugin/" target="_blank">Masked Input  Plugin</a></h2>
<p><a href="http://digitalbush.com/projects/masked-input-plugin/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_15.jpg" alt="Masked Input Plugin - jQuery Form Plugin" width="320" height="226" /></a>The  <a href="http://digitalbush.com/projects/masked-input-plugin/" target="_blank">Masked Input</a> Plugin allows a user to easily enter fixed width input fields where you  would like them to enter the data in a certain format (dates,phone  numbers, etc).<br />
<a href="http://digitalbush.com/projects/masked-input-plugin/" target="_blank">Masked Input  Plugin »</a></p>
<h2><a href="http://decorplanit.com/plugin/" target="_blank">autoNumeric()</a></h2>
<p><a href="http://decorplanit.com/plugin/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_16.jpg" alt="autoNumeric() - jQuery Form Plugin" width="320" height="226" /></a><a href="http://decorplanit.com/plugin/" target="_blank">autoNumeric()</a> is a flexible International numeric formatter, that will automatically  place a thousand separator as you type and supports nine different  rounding methods.<br />
<a href="http://decorplanit.com/plugin/" target="_blank">autoNumeric() »</a></p>
<h1>Form  Upload Plugins</h1>
<h2><a href="http://valums.com/ajax-upload/" target="_blank">AJAX Upload</a></h2>
<p><a href="http://valums.com/ajax-upload/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_17.jpg" alt="AJAX Upload - jQuery Form Plugin" width="320" height="226" /></a><a href="http://valums.com/ajax-upload/" target="_blank">AJAX Upload</a> allows you to easily upload multiple files without refreshing the page  and can use any element to show the file selection window.<br />
<a href="http://valums.com/ajax-upload/" target="_blank">AJAX Upload »</a></p>
<h2><a href="http://pixeline.be/experiments/jqUploader/" target="_blank">jqUploader:  jQuery Plugin for File Upload and Progressbar</a></h2>
<p><a href="http://pixeline.be/experiments/jqUploader/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_18.jpg" alt="jqUploader: jQuery Plugin for File Upload and Progressbar - jQuery  Form Plugin" width="320" height="226" /></a><a href="http://pixeline.be/experiments/jqUploader/" target="_blank">jqUploader</a> is a  plugin that substitutes the html file input fields with a flash-based  file upload widget, allowing you to display a progressbar and  percentage.<br />
<a href="http://pixeline.be/experiments/jqUploader/" target="_blank">jqUploader »</a></p>
<h2><a href="http://www.uploadify.com/" target="_blank">Uploadify</a></h2>
<p><a href="http://www.uploadify.com/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_19.jpg" alt="Uploadify - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.uploadify.com/" target="_blank">Uploadify</a> is a  plugin that allows the easy integration of a multiple (or single) file  uploads on your website.  It requires Flash and any backend development  language.  An array of options allow for full customization for advanced  users, but basic implementation is so easy that even coding novices can  do it.<br />
<a href="http://www.uploadify.com/" target="_blank">Uploadify  »</a></p>
<h2><a href="http://nixbox.com/demos/jquery-uploadprogress.php" target="_blank">jQuery  Uploadprogress Plugin</a></h2>
<p><a href="http://nixbox.com/demos/jquery-uploadprogress.php" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_20.jpg" alt="jQuery Uploadprogress Plugin - jQuery Form Plugin" width="320" height="226" /></a>This plugin will augment a standard file upload form  with a transparent background upload and add a progress meter that will  keep you graphically informed.<br />
<a href="http://nixbox.com/demos/jquery-uploadprogress.php" target="_blank">jQuery  Uploadprogress »</a></p>
<h1>Form Skinning and Customisation</h1>
<h2><a href="http://widowmaker.kiev.ua/checkbox/" target="_blank">jQuery  Checkbox</a></h2>
<p><a href="http://widowmaker.kiev.ua/checkbox/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_21.jpg" alt="jQuery Checkbox - jQuery Form Plugin" width="320" height="226" /></a>The  <a href="http://widowmaker.kiev.ua/checkbox/" target="_blank">jQuery  Checkbox</a> plugin is a lightweight custom styled checkbox  implementation that can also work with radio buttons.<br />
<a href="http://widowmaker.kiev.ua/checkbox/" target="_blank">jQuery  Checkbox »</a></p>
<h2><a href="http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/" target="_blank">Jqtransform  – jQuery form plugin</a></h2>
<p><a href="http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_22.jpg" alt="Jqtransform - jQuery form plugin - jQuery Form Plugin" width="320" height="226" /></a>This plugin is a <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> styling plugin  which allows you to skin form elements with relative ease.<br />
<a href="http://www.dfc-e.com/metiers/multimedia/opensource/jqtransform/" target="_blank">Jqtransform  »</a></p>
<h2><a href="http://fuelyourcoding.com/scripts/infield/" target="_blank">In-Field Labels jQuery  Plugin</a></h2>
<p><a href="http://fuelyourcoding.com/scripts/infield/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_23.jpg" alt="In-Field Labels jQuery Plugin - jQuery Form Plugin" width="320" height="226" /></a>This is a simple plugin that turns properly formatted  HTML forms into forms with in-field label support. Labels fade when the  field is focussed and disappear when text entry begins. Clearing a field  and leaving brings back the label.<br />
<a href="http://fuelyourcoding.com/scripts/infield/" target="_blank">In-Field Labels jQuery  Plugin »</a></p>
<h2><a href="http://www.emblematiq.com/lab/niceforms/" target="_blank">Niceforms</a></h2>
<p><a href="http://www.emblematiq.com/lab/niceforms/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_24.jpg" alt="Niceforms - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.emblematiq.com/lab/niceforms/" target="_blank">Niceforms</a> is a script that will replace the most commonly used form elements with  custom designed ones. You can either use the default theme that is  provided or you can even develop your own look with minimal effort.<br />
<a href="http://www.emblematiq.com/lab/niceforms/" target="_blank">Niceforms  »</a></p>
<h2><a href="http://plugins.jquery.com/project/jNice" target="_blank">jNice</a></h2>
<p><a href="http://plugins.jquery.com/project/jNice" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_26.jpg" alt="jNice - jQuery Form Plugin" width="320" height="226" /></a><a href="http://plugins.jquery.com/project/jNice" target="_blank">jNice</a> makes it easy to style rough and simple html forms into beautiful web  forms, checkboxes, input elements and selectboxes by creating custom  looking form elements, that function just like normal form elements.<br />
<a href="http://plugins.jquery.com/project/jNice" target="_blank">jNice  »</a></p>
<h2><a href="http://pixelmatrixdesign.com/uniform/#" target="_blank">Uniform – Sexy forms with  jQuery</a></h2>
<p><a href="http://pixelmatrixdesign.com/uniform/#" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_27.jpg" alt="Uniform - Sexy forms with jQuery - jQuery Form Plugin" width="320" height="226" /></a><a href="http://pixelmatrixdesign.com/uniform/#" target="_blank">Uniform</a> masks your  standard form controls with custom themed controls. It works in sync  with your real form elements to ensure accessibility and compatibility.<br />
<a href="http://pixelmatrixdesign.com/uniform/#" target="_blank">Uniform  »</a></p>
<h2><a href="http://www.no-margin-for-errors.com/projects/prettyCheckboxes/" target="_blank">prettyCheckboxes</a></h2>
<p><a href="http://www.no-margin-for-errors.com/projects/prettyCheckboxes/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_28.jpg" alt="prettyCheckboxes - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.no-margin-for-errors.com/projects/prettyCheckboxes/" target="_blank">prettyCheckboxes</a> is for developers who wants to maintain a consistent style for  checkboxes across all browsers. By using this script you wont loose any  regular input usability.<br />
<a href="http://www.no-margin-for-errors.com/projects/prettyCheckboxes/" target="_blank">prettyCheckboxes  »</a></p>
<h1>Form Select and Combo Boxes</h1>
<h2><a href="http://jquery.sanchezsalvador.com/page/jquerycombobox.aspx" target="_blank">jquery.combobox</a></h2>
<p><a href="http://jquery.sanchezsalvador.com/page/jquerycombobox.aspx" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_29.jpg" alt="jquery.combobox - jQuery Form Plugin" width="320" height="226" /></a><a href="http://jquery.sanchezsalvador.com/page/jquerycombobox.aspx" target="_blank">jquery.combobox</a> is an unobtrusive way of creating a HTML type combobox from a existing  HTML Select element(s).<br />
<a href="http://jquery.sanchezsalvador.com/page/jquerycombobox.aspx" target="_blank">jquery.combobox  »</a></p>
<h2><a href="http://www.marghoobsuleman.com/jquery-image-dropdown" target="_blank">JavaScript  Image Combobox</a></h2>
<p><a href="http://www.marghoobsuleman.com/jquery-image-dropdown" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_30.jpg" alt="JavaScript Image Combobox - jQuery Form Plugin" width="320" height="226" /></a>The fully skinnable <a href="http://www.marghoobsuleman.com/jquery-image-dropdown" target="_blank">Image  Combobox</a> plugin allows you to add an icon with each option that  works with your existing &#8220;select&#8221; element.<br />
<a href="http://www.marghoobsuleman.com/jquery-image-dropdown" target="_blank">JavaScript  Image Combobox »</a></p>
<h2><a href="http://mypocket-technologies.com/jquery/SelectBoxPlugin/" target="_blank">SelectBox  Plug-in</a></h2>
<p><a href="http://mypocket-technologies.com/jquery/SelectBoxPlugin/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_31.jpg" alt="SelectBox Plug-in - jQuery Form Plugin" width="320" height="226" /></a><a href="http://mypocket-technologies.com/jquery/SelectBoxPlugin/" target="_blank">SelectBox  Plug-in »</a></p>
<h2><a href="http://www.stevefenton.co.uk/Content/Jquery-Two-Sided-Multi-Selector/" target="_blank">Two  Sided Multi Selector</a></h2>
<p><a href="http://www.stevefenton.co.uk/Content/Jquery-Two-Sided-Multi-Selector/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_32.jpg" alt="jQuery Two Sided Multi Selector - jQuery Form Plugin" width="320" height="226" /></a>This plugin converts a multi select list into a  two-sided multi-select list. This means you display a list of options in  the left hand box and items you select are moved into the right hand  box.<br />
<a href="http://www.stevefenton.co.uk/Content/Jquery-Two-Sided-Multi-Selector/" target="_blank">Two  Sided Multi Selector »</a></p>
<h2><a href="http://rmm5t.github.com/jquery-flexselect/" target="_blank">flexselect</a></h2>
<p><a href="http://rmm5t.github.com/jquery-flexselect/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_33.jpg" alt="flexselect - jQuery Form Plugin" width="320" height="226" /></a><a href="http://rmm5t.github.com/jquery-flexselect/" target="_blank">flexselect</a> takes the select box, and creates a hidden input element to track the  associated value and creates a text input for the selection. It uses the  LiquidMetal  scoring algorithm to narrow the selection.<br />
<a href="http://rmm5t.github.com/jquery-flexselect/" target="_blank">flexselect  »</a></p>
<h1>Form Time and Date Pickers</h1>
<h2><a href="http://haineault.com/media/jquery/ui-timepickr/page/" target="_blank">jQuery.timepickr.js</a></h2>
<p><a href="http://haineault.com/media/jquery/ui-timepickr/page/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_34.jpg" alt="jQuery.timepickr.js - jQuery Form Plugin" width="320" height="226" /></a><a href="http://haineault.com/media/jquery/ui-timepickr/page/" target="_blank">jQuery.timepickr.js</a> has been developed in a attempt to make the process of inputing time in  a form as easy and natural as possible.<br />
<a href="http://haineault.com/media/jquery/ui-timepickr/page/" target="_blank">jQuery.timepickr.js  »</a></p>
<h2><a href="http://www.eyecon.ro/datepicker/" target="_blank">DatePicker</a></h2>
<p><a href="http://www.eyecon.ro/datepicker/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_35.jpg" alt="DatePicker - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.eyecon.ro/datepicker/" target="_blank">DatePicker</a> is a feature rich and easy to customize plugin that allows for single,  multiple or range selection dates.<br />
<a href="http://www.eyecon.ro/datepicker/" target="_blank">DatePicker »</a></p>
<h2><a href="http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/" target="_blank">jQuery  datePicker</a></h2>
<p><a href="http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_36.jpg" alt="jQuery datePicker - jQuery Form Plugin" width="320" height="226" /></a>This  is a clean, flexible and unobtrusive plugin for <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> which allows you  to easily add date inputing functionality to your web forms and pages.<br />
<a href="http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/" target="_blank">jQuery  datePicker »</a></p>
<h2><a href="http://wiki.github.com/robmonie/jquery-week-calendar/" target="_blank">jQuery Week  Calendar</a></h2>
<p><a href="http://wiki.github.com/robmonie/jquery-week-calendar/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_37.jpg" alt="jQuery Week Calendar - jQuery Form Plugin" width="320" height="226" /></a>The <a href="http://wiki.github.com/robmonie/jquery-week-calendar/" target="_blank">jQuery Week  Calendar</a> plugin provides a simple and flexible way of including a  weekly calendar in your application and has been inspired by other  online weekly calendars such as Google calendar.<br />
<a href="http://wiki.github.com/robmonie/jquery-week-calendar/" target="_blank">jQuery Week  Calendar »</a></p>
<h1>Form Auto-Suggest</h1>
<h2><a href="http://code.drewwilson.com/entry/autosuggest-jquery-plugin" target="_blank">AutoSuggest</a></h2>
<p><a href="http://code.drewwilson.com/entry/autosuggest-jquery-plugin" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_38.jpg" alt="AutoSuggest - jQuery Form Plugin" width="320" height="226" /></a><a href="http://code.drewwilson.com/entry/autosuggest-jquery-plugin" target="_blank">AutoSuggest</a> is a lightweight <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> plugin that will will dynamically create all  the HTML elements that is needed for turning any regular text input  box  into an auto-complete box.<br />
<a href="http://code.drewwilson.com/entry/autosuggest-jquery-plugin" target="_blank">AutoSuggest  »</a></p>
<h2><a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/" target="_blank">Autocomplete</a></h2>
<p><a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_39.jpg" alt="Autocomplete - jQuery Form Plugin" width="320" height="226" /></a>By  giving an autocompleted field focus or entering something into it, the  plugin starts searching for matching entries and displays a list of  values to choose from. By entering more characters, the user can filter  down the list to better matches.<br />
<a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/" target="_blank">Autocomplete  »</a></p>
<h2><a href="http://www.devbridge.com/projects/autocomplete/jquery/" target="_blank">Ajax  Autocomplete</a></h2>
<p><a href="http://www.devbridge.com/projects/autocomplete/jquery/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_40.jpg" alt="Ajax Autocomplete for jQuery - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.devbridge.com/projects/autocomplete/jquery/" target="_blank">Ajax  Autocomplete</a> allows you to easily create autocomplete/autosuggest  boxes for text input fields with every <a href="http://www.iwanna.cn/tags/query/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Query">query</a> result being cached and  pulled from local cache for the same repeating <a href="http://www.iwanna.cn/tags/query/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Query">query</a>. If there are no  results for a particular <a href="http://www.iwanna.cn/tags/query/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Query">query</a> it stops sending requests to the server  for other queries with the same root.<br />
<a href="http://www.devbridge.com/projects/autocomplete/jquery/" target="_blank">Ajax  Autocomplete »</a></p>
<h2><a href="http://www.web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-engine/" target="_blank">FaceBook  Like – jQuery and autosuggest Search Engine</a></h2>
<p><a href="http://www.web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-engine/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_41.jpg" alt="FaceBook Like – jQuery and autosuggest Search Engine - jQuery Form  Plugin" width="320" height="226" /></a><a href="http://www.web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-engine/" target="_blank">FaceBook  Like</a> is a powerful <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> plugin that transform an input field into  a real time autocompletion search engine, designed, as the name  suggests, similiar to the one on  Facebook.<br />
<a href="http://www.web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-engine/" target="_blank">FaceBook  LikePlugin »</a></p>
<h1>Form Validation Plugins</h1>
<h2><a href="http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/" target="_blank">A  jQuery inline form validation, because validation is a mess</a></h2>
<p><a href="http://www.position-absolute.com/articles/jquery-form-validator-because-form-validation-is-a-mess/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_42.jpg" alt="A jQuery inline form validation, because validation is a mess -  jQuery Form Plugin" width="320" height="226" /></a>When an error needs to  be displayed, this script creates a div and positions it in the top  right corner of the input. This way you don’t have to worry about your  HTML form structure. The rounded corners and shadows are pure CSS3 and  degrade well in non compliant browsers.</p>
<h2><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank">Validation</a></h2>
<p><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_43.jpg" alt="Validation - jQuery Form Plugin" width="320" height="226" /></a>The <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank">Validation</a> plugin is one of the oldest <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> plugins (started in July 2006)  available that has proved itself due to reliabilty, ease of use and  extensive docs.<br />
<a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank">Validation  »</a></p>
<h2><a href="http://www.webdeveloperjuice.com/2010/03/22/highly-customizable-yet-simple-form-validation-jquery-plugin/" target="_blank">Highly  Customizable Yet Simple Form Validation</a></h2>
<p><a href="http://www.webdeveloperjuice.com/2010/03/22/highly-customizable-yet-simple-form-validation-jquery-plugin/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_44.jpg" alt="Highly Customizable Yet Simple Form Validation - jQuery Form  Plugin" width="320" height="226" /></a>With this highly customizable  plugin the user can set his own class to define the rule, set events  onError and OnValid for a particular class and you can also add their  own effects, may be <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a> animate().<br />
<a href="http://www.webdeveloperjuice.com/2010/03/22/highly-customizable-yet-simple-form-validation-jquery-plugin/" target="_blank">Highly  Customizable Form Validation »</a></p>
<h2><a href="http://livevalidation.com/" target="_blank">LiveValidation – Validation as you  type</a></h2>
<p><a href="http://livevalidation.com/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_45.jpg" alt="LiveValidation - Validation as you type - jQuery Form Plugin" width="320" height="226" /></a><a href="http://livevalidation.com/" target="_blank">LiveValidation</a> is a small open  source <a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">javascript</a> library for making client-side validation quick, easy,  and powerful. It comprises of two main parts. Firstly, it provides  developers with a rich set of core validation methods, which can also be  used outside the context of forms. Secondly, it provides your visitors  with real-time validation information as they fill out forms, helping  them to get it right first time.<br />
<a href="http://livevalidation.com/" target="_blank">LiveValidation »</a></p>
<h2><a href="http://demos.usejquery.com/ketchup-plugin/index.html" target="_blank">Ketchup  Plugin</a></h2>
<p><a href="http://demos.usejquery.com/ketchup-plugin/index.html" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_46.jpg" alt="Ketchup Plugin - jQuery Form Plugin" width="320" height="226" /></a><a href="http://demos.usejquery.com/ketchup-plugin/index.html" target="_blank">Ketchup  Plugin</a> is a slim <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> Plugin that validates your forms. It aims to  be very flexible and extendable for its appearance and functionality.<br />
<a href="http://demos.usejquery.com/ketchup-plugin/index.html" target="_blank">Ketchup  Plugin »</a></p>
<h2><a href="http://www.codylindley.com/blogstuff/js/jtip/" target="_blank">jTip – The Jquery  Tool Tip</a></h2>
<p><a href="http://www.codylindley.com/blogstuff/js/jtip/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_47.jpg" alt="jTip - The Jquery Tool Tip - jQuery Form Plugin" width="320" height="226" /></a>jTip pulls content into a tool tip using the  HttpXMLRequest object. By adding a class attribute value of “jTip” to a  link element you can create a tooltip from the content found in the file  the href is pointing too.<br />
<a href="http://www.codylindley.com/blogstuff/js/jtip/" target="_blank">jTip »</a></p>
<h2><a href="http://www.geektantra.com/2009/09/jquery-live-form-validation/" target="_blank">jQuery  Live Form Validation</a></h2>
<p><a href="http://www.geektantra.com/2009/09/jquery-live-form-validation/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_49.jpg" alt="jQuery Live Form Validation - jQuery Form Plugin" width="320" height="226" /></a>This plugin helps you to easily create form validations  with high flexibility and is a packaged with a huge set of options.<br />
<a href="http://www.geektantra.com/2009/09/jquery-live-form-validation/" target="_blank">jQuery  Live Form Validation »</a></p>
<h2><a href="http://www.unwrongest.com/projects/valid8/" target="_blank">Valid8 – An input  field validation plugin</a></h2>
<p><a href="http://www.unwrongest.com/projects/valid8/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_50.jpg" alt="Valid8 – An input field validation plugin for Jquery - jQuery Form  Plugin" width="320" height="226" /></a><a href="http://www.unwrongest.com/projects/valid8/" target="_blank">Valid8</a> solves both  simple and complex validation scenarios. Everything from a basic  required field to regular expressions, <a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">ajax</a> requests and arbitrary  <a href="http://www.iwanna.cn/tags/javascript/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JavaScript">javascript</a> functions.<br />
<a href="http://www.unwrongest.com/projects/valid8/" target="_blank">Valid8 – An input  field validation plugin »</a></p>
<h2><a href="http://www.overset.com/2008/07/31/jval-jquery-form-field-validation-plugin/" target="_blank">jVal  – jQuery Form Field Validation Plugin</a></h2>
<p><a href="http://www.overset.com/2008/07/31/jval-jquery-form-field-validation-plugin/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.specky.netdna-cdn.com/wp-content/uploads/2010/06/jquery_form_plugin_51.jpg" alt="jVal - jQuery Form Field Validation Plugin - jQuery Form Plugin" width="320" height="226" /></a><a href="http://www.overset.com/2008/07/31/jval-jquery-form-field-validation-plugin/" target="_blank">jVal</a> is a <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> form field validation plugin that provides an appealing  animated message flyout that doesn&#8217;t impede form layout/design while  being user-friendly.<br />
<a href="http://www.overset.com/2008/07/31/jval-jquery-form-field-validation-plugin/" target="_blank">jVal  »</a></p>
<h1>The Original <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> Plugin</h1>
<h2><a href="http://www.malsup.com/jquery/form/#getting-started" target="_blank">jQuery Form  Plugin</a></h2>
<p><a href="http://www.malsup.com/jquery/form/" target="_blank"><img style="float:left;margin:0 5px 10px 0;" src="http://speckyboy.com/wp-content/uploads/2010/06/jquery_form_plugin_50.jpg" alt="jQuery Form Plugin - jQuery Form Plugin" width="320" height="226" /></a>And  if all of the rest of the plugins on this page can’t help, you can  always rely on the original <a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a> form plugin: <a href="http://www.malsup.com/jquery/form/#getting-started" target="_blank">jQuery Form  Plugin »</a></p>
<div style="clear:both;"></div>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/08/4164/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/08/4164/#comments">1条评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/08/4164/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/08/4164/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/08/4164/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/plugin/" title="Plugin" rel="tag nofollow">Plugin</a>, <a href="http://www.iwanna.cn/topics/develope/plugin-develope/" title="Plugin" rel="tag nofollow">Plugin</a>, <a href="http://www.iwanna.cn/tags/translate/" title="Translate" rel="tag nofollow">Translate</a>, <a href="http://www.iwanna.cn/topics/iwanna/translate-iwanna/" title="Translate" rel="tag nofollow">Translate</a>, <a href="http://www.iwanna.cn/tags/translates/" title="翻译" rel="tag nofollow">翻译</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2010/05/08/2812/" title="30个最好的jQuery表单插件 (2010年05月8日)">30个最好的jQuery表单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/04/23/811/" title="FCBKcomplete v 2.02 (2009年04月23日)">FCBKcomplete v 2.02</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/22/4147/" title="25个优秀的jQuery滑块教程和插件 (2010年06月22日)">25个优秀的jQuery滑块教程和插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/17/3115/" title="11 个优秀的制作移动友好网站的解决方案 (2010年05月17日)">11 个优秀的制作移动友好网站的解决方案</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/07/05/1923/" title="转换设计原图 PSD 为 HTML (2009年07月5日)">转换设计原图 PSD 为 HTML</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/22/3294/" title="深色调社交图标：免费且高质量的社交媒体图标集 (2010年05月22日)">深色调社交图标：免费且高质量的社交媒体图标集</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/11/4460/" title="推荐8个独特应用的JQuery拖放插件 (2010年07月11日)">推荐8个独特应用的JQuery拖放插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/18/3210/" title="如何正确购买一个已经存在的域名(SEO友好) (2010年05月18日)">如何正确购买一个已经存在的域名(SEO友好)</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/27/1176/" title="如何备份所有的浏览器 &#8211; 5 个小贴士(Google Chrome, Firefox, Safari, Internet Explorer, and Opera) (2009年05月27日)">如何备份所有的浏览器 &#8211; 5 个小贴士(Google Chrome, Firefox, Safari, Internet Explorer, and Opera)</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/08/4164/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>10+个jQuery图片滚动插件介绍</title>
		<link>http://www.iwanna.cn/archives/2010/07/07/4401/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/07/4401/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 12:57:14 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4401</guid>
		<description><![CDATA[前阵子为大家奉献上的是5个jquery图片画廊插件，继续此类风格，本次为大家收集的是10+个jQuery图片滚动插件，希望对您的日常工作会有很大的帮助，在页面的最后奉献的是用jQuery插件实现图片滚动的几个站点，希望您会喜欢！！
1、jCarousel

这款jquery图片滚动插件用的人很多，功能上颇为强大，你可以控制是水平滚动还是垂直滚动。

2、jCarousel Lite

这款插件优势在于小巧，只有2K的js，当然功能上会差些。
3、jQuery Carousel

更像一个幻灯片，你可以控制图片滑动方向。
4、jQuery Infinite Carousel

5、LoopedCarousel

6、MovingBoxes

点此下载
7、infinite-carousel

点此下载
8、Agile Carousel


查看示例
点此下载


（注：请从服务器端启动，不然无法正确运行）
9、jMyCarousel


查看示例
点此下载

10、easyslider1.7

点此下载
想要把图片滚动应用到你的站点中，不可避免要对这些jquery图片滚动插件的样式进行重写，接下来来推荐几个漂亮的应用图片滚动的站点。
1、Branded07

2、Deluge   Studios

3、Golf Working

4、Dazzle Cat

5、Bret Glassett

6、What Is XV


© 我想网 Akon 所有 , 2010. &#124;
永久链接 &#124;
没有评论 &#124;
提交到
Google Reader
鲜果
抓虾


	标签：JQuery, JQuery, Plugin, Plugin

	您可能会感兴趣的其他文章
	
	推荐8个独特应用的JQuery拖放插件 
	FCBKcomplete v 2.02 
	6个jQuery图标插件的应用程序 
	50个表单功能，验证，安全和自定义化的jQuery插件 
	30个最好的jQuery表单插件 
	30+ 新鲜惊奇的 jQuery 插件与教程 
	21个演示展示强大的jQuery特效 
	2010年4月：最佳的jQuery插件 
	10 个帮助你处理Web页面层布局的jQuery插件 
	简单的JQuery聚光灯效果教程 



Feed enhanced by Better Feed from  Ozh
]]></description>
			<content:encoded><![CDATA[<p>前阵子为大家奉献上的是<strong><a href="http://www.iwanna.cn/archives/2010/06/21/4129/" title="5个jquery图片画廊插件">5个jquery图片画廊插件</a></strong>，继续此类风格，本次为大家收集的是<strong><a href="http://www.iwanna.cn/archives/2010/07/07/4401/" title="10+个jQuery图片滚动插件介绍">10+个jQuery图片滚动插件</a></strong>，希望对您的日常工作会有很大的帮助，在页面的最后奉献的是用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jQuery</a>插件实现图片滚动的几个站点，希望您会喜欢！！</p>
<h4>1、<a href="http://sorgalla.com/projects/jcarousel/" target="_blank">jCarousel</a></h4>
<p><img title="jcarousel" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/jcarousel.png" alt="" width="456" height="296" /></p>
<p>这款<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>图片滚动插件用的人很多，功能上颇为强大，你可以控制是水平滚动还是垂直滚动。<br />
<span id="more-4401"></span></p>
<h4>2、<a href="http://www.gmarwaha.com/jquery/jcarousellite/" target="_blank">jCarousel Lite</a></h4>
<p><img title="lite-jquery-carousel-plugins-resources-tutorials-examples" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/lite-jquery-carousel-plugins-resources-tutorials-examples.jpg" alt="" width="570" height="269" /></p>
<p>这款插件优势在于小巧，只有2K的js，当然功能上会差些。</p>
<h4>3、<a href="http://thomlx.free.fr/jquery/jquery_carousel.htm" target="_blank">jQuery Carousel</a></h4>
<p><img title="great-jquery-carousel-plugins-resources-tutorials-examples" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/great-jquery-carousel-plugins-resources-tutorials-examples.jpg" alt="" width="570" height="350" /></p>
<p>更像一个幻灯片，你可以控制图片滑动方向。</p>
<h4>4、<a href="http://jqueryfordesigners.com/demo/infinite-carousel.html" target="_blank">jQuery Infinite Carousel</a></h4>
<p><img title="screencast-tutorial-jquery-carousel-plugins-resources-tutorials-examples" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/screencast-tutorial-jquery-carousel-plugins-resources-tutorials-examples.jpg" alt="" width="458" height="234" /></p>
<h4>5、<a href="http://github.com/nathansearles/loopedCarousel/" target="_blank">LoopedCarousel</a></h4>
<p><img title="loopedcarousel" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/loopedcarousel.png" alt="" width="537" height="242" /></p>
<h4>6、<a title="点击查看—&gt;MovingBoxes-JQ图片滚动插件" rel="bookmark" href="http://www.36ria.com/319">MovingBoxes</a></h4>
<p><img src="http://www.36ria.com/wp-content/uploads/snap1.jpg" alt="" width="583" height="177" /><br />
<a class="btn-download" title="名称：MovingBoxes，文件大小：786.4 KB" href="http://www.36ria.com/wp-content/plugins/download-monitor/download.php?id=28">点此下载</a></p>
<h4>7、<a href="http://www.36ria.cn/?p=316">infinite-carousel</a></h4>
<p><img src="http://www.36ria.com/wp-content/uploads/2009/08/snap23.jpg" alt="" width="338" height="169" /><br />
<a class="btn-download" title="名称：jquery-infinite-carousel，文件大小：" href="http://www.36ria.com/wp-content/plugins/download-monitor/download.php?id=27">点此下载</a></p>
<h4>8、<a href="http://www.agilecarousel.com/">Agile Carousel</a></h4>
<p><img title="agilecarousel" src="http://www.36ria.com/wp-content/uploads/agilecarousel.jpg" alt="agilecarousel" width="370" height="138" /></p>
<ul>
<li><a target="_blank" class="btn-view-demo" href="http://www.agilecarousel.com/examples/full_example">查看示例</a></li>
<li class="l"><a class="btn-download" title="名称：agile_carousel，文件大小：79.05 KB" href="http://www.36ria.com/wp-content/plugins/download-monitor/download.php?id=62">点此下载</a>
</li>
</ul>
<p>（注：请从服务器端启动，不然无法正确运行）</p>
<h4>9、<a href="http://www.enova-tech.net/lab/jMyCarousel/">jMyCarousel</a></h4>
<p><img title="jmycarousel" src="http://www.36ria.com/wp-content/uploads/jmycarousel.jpg" alt="jmycarousel" width="482" height="105" /></p>
<ul class="tow-columns clearfix">
<li class="l"><a target="_blank" class="btn-view-demo" href="http://www.enova-tech.net/eng/lab/jMyCarousel/1">查看示例</a></li>
<li class="l"><a class="btn-download" title="名称：jMyCarousel，文件大小：470.65 KB" href="http://www.36ria.com/wp-content/plugins/download-monitor/download.php?id=63">点此下载</a></li>
</ul>
<h4>10、<a href="http://www.36ria.cn/312">easyslider1.7</a></h4>
<p><img src="http://www.36ria.cn/wp-content/uploads/2009/08/snap16.jpg" alt="" width="568" height="345" /><br />
<a class="btn-download" title="名称：easyslider1.7，文件大小：" href="http://www.36ria.com/wp-content/plugins/download-monitor/download.php?id=26">点此下载</a></p>
<p>想要把图片滚动应用到你的站点中，不可避免要对这些<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>图片滚动插件的样式进行重写，接下来来推荐几个漂亮的应用图片滚动的站点。</p>
<h4>1、<a href="http://www.branded07.com/" target="_blank">Branded07</a></h4>
<p><img title="branded-07-jquery-carousel-plugins-resources-tutorials-examples" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/branded-07-jquery-carousel-plugins-resources-tutorials-examples.jpg" alt="" width="570" height="350" /></p>
<h4>2、<a href="http://www.delugestudios.com/" target="_blank">Deluge   Studios</a></h4>
<p><img title="deluge-studios-jquery-carousel-plugins-resources-tutorials-examples" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/deluge-studios-jquery-carousel-plugins-resources-tutorials-examples.jpg" alt="" width="570" height="350" /></p>
<h4>3、<a href="http://golfworking.co.uk/" target="_blank">Golf Working</a></h4>
<p><img title="golf-working-jquery-carousel-plugins-resources-tutorials-examples" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/golf-working-jquery-carousel-plugins-resources-tutorials-examples.jpg" alt="" width="570" height="350" /></p>
<h4>4、<a href="http://www.dazzlecat.co.uk/" target="_blank">Dazzle Cat</a></h4>
<p><img title="dazzle-cat-jquery-carousel-plugins-resources-tutorials-examples" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/dazzle-cat-jquery-carousel-plugins-resources-tutorials-examples.jpg" alt="" width="570" height="350" /></p>
<h4>5、<a href="http://bretglassett.com/" target="_blank">Bret Glassett</a></h4>
<p><img title="bret-glassett-jquery-carousel-plugins-resources-tutorials-examples" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/bret-glassett-jquery-carousel-plugins-resources-tutorials-examples.jpg" alt="" width="570" height="350" /></p>
<h4>6、<a href="http://www.whatisxv.com/" target="_blank">What Is XV</a></h4>
<p><img title="what-is-xv-jquery-carousel-plugins-resources-tutorials-examples" src="http://images.uheed.com/iwanna/2010/07/07/jquery-plugin/what-is-xv-jquery-carousel-plugins-resources-tutorials-examples.jpg" alt="" width="570" height="350" /></p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/07/4401/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/07/4401/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/07/4401/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/07/4401/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/07/4401/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/plugin/" title="Plugin" rel="tag nofollow">Plugin</a>, <a href="http://www.iwanna.cn/topics/develope/plugin-develope/" title="Plugin" rel="tag nofollow">Plugin</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2010/07/11/4460/" title="推荐8个独特应用的JQuery拖放插件 (2010年07月11日)">推荐8个独特应用的JQuery拖放插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/04/23/811/" title="FCBKcomplete v 2.02 (2009年04月23日)">FCBKcomplete v 2.02</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/01/1621/" title="6个jQuery图标插件的应用程序 (2009年06月1日)">6个jQuery图标插件的应用程序</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/08/4164/" title="50个表单功能，验证，安全和自定义化的jQuery插件 (2010年07月8日)">50个表单功能，验证，安全和自定义化的jQuery插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/08/2812/" title="30个最好的jQuery表单插件 (2010年05月8日)">30个最好的jQuery表单插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/01/26/2474/" title="30+ 新鲜惊奇的 jQuery 插件与教程 (2010年01月26日)">30+ 新鲜惊奇的 jQuery 插件与教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/23/4691/" title="21个演示展示强大的jQuery特效 (2010年07月23日)">21个演示展示强大的jQuery特效</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/14/2913/" title="2010年4月：最佳的jQuery插件 (2010年05月14日)">2010年4月：最佳的jQuery插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/26/3379/" title="10 个帮助你处理Web页面层布局的jQuery插件 (2010年05月26日)">10 个帮助你处理Web页面层布局的jQuery插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/07/4401/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>网页打开新窗口的解决方案,拒绝屏蔽</title>
		<link>http://www.iwanna.cn/archives/2010/07/06/4383/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/06/4383/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 04:23:38 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4383</guid>
		<description><![CDATA[好久没有写过js了，近日项目中，有个需求就是，新打开窗口页面，对于新窗口我总结以下2点
1.最基本的弹出窗口代码window.open()这个也相对简单，大家都调用过，建义大家用绝对路径(http://)，以下是参数
window.open 弹出新窗口的命令；
&#8216;page.html&#8217; 弹出窗口的文件名； 
&#8216;newwindow&#8217; 弹出窗口的名字（不是文件名），非必须，可用空&#8221;代替； 
height=100 窗口高度； 
width=400 窗口宽度；

top=0 窗口距离屏幕上方的象素值； 
left=0 窗口距离屏幕左侧的象素值； 
toolbar=no 是否显示工具栏，yes为显示； 
menubar，scrollbars 表示菜单栏和滚动栏。 
resizable=no 是否允许改变窗口大小，yes为允许； 
location=no 是否显示地址栏，yes为允许； 
status=no 是否显示状态栏内的信息（通常是文件已经打开），yes为允许； 
用这个方法在浏览器中，基本都会被屏蔽，大家可以通过
var val = window.open(url),返回值来判断
if(!val){
这里表示被屏蔽了，没有成功，。大家可以在这里加个相对应的业务代码。我当时如果处理是如果屏蔽了，
用document.location.href=url内部跳转。
}
2、以上方法最基本的问题没有解决，就是屏蔽。所以告诉大家一个最完美window.open()不会
屏蔽的，道理很简单，就是建一个form.然后提交form，因为form可以在新窗口提高
给大家看看代码吧。
在你的页面里&#60;form action=&#8221;" method=&#8221;get&#8221; target=&#8221;_blank&#8221; id=&#8221;tzForm&#8221; name=&#8221;tzForm&#8221;/&#62;
&#60;div id=&#8221;J_formStr&#8221;&#62;&#60;/div&#62;
&#60;/form&#62;
然后js
function openUrl(urlStr){
var pStr=&#8221;";
if(urlStr.indexOf(&#8220;?&#8221;)!= -1){
var str = urlStr.substr(urlStr.indexOf(&#8220;?&#8221;)+1,urlStr.length);
strs = str.split(&#8220;&#38;&#8221;);
for(var i = 0; i &#60; strs.length; i ++){
pStr=pStr+&#8221;&#60;input type=&#8217;hidden&#8217; name=&#8217;&#8221;+strs[i].split(&#8220;=&#8221;)[0]+&#8221;&#8216; value=&#8217;&#8221;+strs[i].split(&#8220;=&#8221;)[1]+&#8221;&#8216; /&#62;&#8221;;
}
}
document.getElementById(&#8220;J_formStr&#8221;).innerHTML=pStr;
document.tzForm.action=urlStr;
document.tzForm.submit();
}
大家可能会问，为什么还要这多代码。不就是一个提交表单。给大家说说原因吧
(1) 为什么用get，而不用post,在新窗口页面如果用post然后刷新。会有一个提交数据的对话框，所以才用get
(2)用get提交有个很关键的问题，如果你的url提交地址中有相对应的参数，打个比方，***.jsp?a=1&#38;b=2在新窗口中
?a=1&#38;b=2参数丢失掉。所以在上面有个pStr这个就是解析url中的参数，然后动态创建的表单元素，这样参数就不会
丢失。

© 我想网 Akon [...]]]></description>
			<content:encoded><![CDATA[<p>好久没有写过js了，近日项目中，有个需求就是，新打开窗口页面，对于新窗口我总结以下2点<br />
1.最基本的弹出窗口代码window.open()这个也相对简单，大家都调用过，建义大家用绝对路径(<a href="http:///" target="_blank">http://</a>)，以下是参数<br />
window.open 弹出新窗口的命令；<br />
&#8216;page.html&#8217; 弹出窗口的文件名； </p>
<p>&#8216;newwindow&#8217; 弹出窗口的名字（不是文件名），非必须，可用空&#8221;代替； </p>
<p>height=100 窗口高度； </p>
<p>width=400 窗口宽度；<br />
<span id="more-4383"></span><br />
top=0 窗口距离屏幕上方的象素值； </p>
<p>left=0 窗口距离屏幕左侧的象素值； </p>
<p>toolbar=no 是否显示工具栏，yes为显示； </p>
<p>menubar，scrollbars 表示菜单栏和滚动栏。 </p>
<p>resizable=no 是否允许改变窗口大小，yes为允许； </p>
<p>location=no 是否显示地址栏，yes为允许； </p>
<p>status=no 是否显示状态栏内的信息（通常是文件已经打开），yes为允许； </p>
<p>用这个方法在浏览器中，基本都会被屏蔽，大家可以通过</p>
<p>var val = window.open(url),返回值来判断</p>
<p>if(!val){</p>
<p>这里表示被屏蔽了，没有成功，。大家可以在这里加个相对应的业务代码。我当时如果处理是如果屏蔽了，</p>
<p>用document.location.href=url内部跳转。</p>
<p>}</p>
<p>2、以上方法最基本的问题没有解决，就是屏蔽。所以告诉大家一个最完美window.open()不会</p>
<p>屏蔽的，道理很简单，就是建一个form.然后提交form，因为form可以在新窗口提高</p>
<p>给大家看看代码吧。</p>
<p>在你的页面里&lt;form action=&#8221;" method=&#8221;get&#8221; target=&#8221;_blank&#8221; id=&#8221;tzForm&#8221; name=&#8221;tzForm&#8221;/&gt;</p>
<p>&lt;div id=&#8221;J_formStr&#8221;&gt;&lt;/div&gt;</p>
<p>&lt;/form&gt;</p>
<p>然后js</p>
<p>function openUrl(urlStr){</p>
<p>var pStr=&#8221;";</p>
<p>if(urlStr.indexOf(&#8220;?&#8221;)!= -1){</p>
<p>var str = urlStr.substr(urlStr.indexOf(&#8220;?&#8221;)+1,urlStr.length);</p>
<p>strs = str.split(&#8220;&amp;&#8221;);</p>
<p>for(var i = 0; i &lt; strs.length; i ++){</p>
<p>pStr=pStr+&#8221;&lt;input type=&#8217;hidden&#8217; name=&#8217;&#8221;+strs[i].split(&#8220;=&#8221;)[0]+&#8221;&#8216; value=&#8217;&#8221;+strs[i].split(&#8220;=&#8221;)[1]+&#8221;&#8216; /&gt;&#8221;;</p>
<p>}</p>
<p>}</p>
<p>document.getElementById(&#8220;J_formStr&#8221;).innerHTML=pStr;</p>
<p>document.tzForm.action=urlStr;</p>
<p>document.tzForm.submit();</p>
<p>}</p>
<p>大家可能会问，为什么还要这多代码。不就是一个提交表单。给大家说说原因吧</p>
<p>(1) 为什么用get，而不用post,在新窗口页面如果用post然后刷新。会有一个提交数据的对话框，所以才用get</p>
<p>(2)用get提交有个很关键的问题，如果你的url提交地址中有相对应的参数，打个比方，***.jsp?a=1&amp;b=2在新窗口中</p>
<p>?a=1&amp;b=2参数丢失掉。所以在上面有个pStr这个就是解析url中的参数，然后动态创建的表单元素，这样参数就不会</p>
<p>丢失。</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/06/4383/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/06/4383/#comments">2 条评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/06/4383/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/06/4383/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/06/4383/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/" title="JavaScript" rel="tag nofollow">JavaScript</a>, <a href="http://www.iwanna.cn/tags/javascript/" title="JavaScript" rel="tag nofollow">JavaScript</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2009/04/29/894/" title="页面输出时一些常用的小技巧 (2009年04月29日)">页面输出时一些常用的小技巧</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/03/31/79/" title="表单元素：40个CSS/JS风格和功能技术处理 (2009年03月31日)">表单元素：40个CSS/JS风格和功能技术处理</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/04/29/2874/" title="相见恨晚的一些 JavaScript 技巧 (2010年04月29日)">相见恨晚的一些 JavaScript 技巧</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/09/18/2252/" title="用JS制作的网页版NES模拟器 IE8直接出局 (2009年09月18日)">用JS制作的网页版NES模拟器 IE8直接出局</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/03/31/77/" title="用css+js控制图片大小的方法 (2009年03月31日)">用css+js控制图片大小的方法</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/02/17/2516/" title="有关 JavaScript 的 10 件让人费解的事情 (2010年02月17日)">有关 JavaScript 的 10 件让人费解的事情</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/11/29/2396/" title="新 API 寻求让 JavaScript 操作本地文件 (2009年11月29日)">新 API 寻求让 JavaScript 操作本地文件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/17/1085/" title="并发下载javascript (2009年05月17日)">并发下载javascript</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/13/4521/" title="常用JS验证函数总结 (2010年07月13日)">常用JS验证函数总结</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/05/24/3340/" title="如何用 JavaScript 检测 IE8 浏览器的文档版本 (2010年05月24日)">如何用 JavaScript 检测 IE8 浏览器的文档版本</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/06/4383/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CSS3+JQuery实现固定头部的导航菜单</title>
		<link>http://www.iwanna.cn/archives/2010/07/02/4328/</link>
		<comments>http://www.iwanna.cn/archives/2010/07/02/4328/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 14:26:26 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4328</guid>
		<description><![CDATA[

查看示例
点此下载

效果说明：当你滚动页面的时候，菜单会放大，固定于头部一起滚动。
制作教程
一、创建如下的菜单结构


&#60;div id=&#8221;navi&#8221;&#62;
 &#60;div id=&#8221;menu&#8221; class=&#8221;default&#8221;&#62;
 &#60;ul&#62;
 &#60;li&#62;&#60;a href=&#8221;#&#8221;&#62;首页&#60;/a&#62;&#60;/li&#62;
 &#60;li&#62;&#60;a href=&#8221;#&#8221;&#62;jquery&#60;/a&#62;&#60;/li&#62;
 &#60;li&#62;&#60;a href=&#8221;#&#8221;&#62;设计&#60;/a&#62;&#60;/li&#62;
 &#60;li&#62;&#60;a href=&#8221;#&#8221;&#62;flex&#60;/a&#62;&#60;/li&#62;
 &#60;li&#62;&#60;a href=&#8221;#&#8221;&#62;air&#60;/a&#62;&#60;/li&#62;
 &#60;li&#62;&#60;a href=&#8221;#&#8221;&#62;ajax&#60;/a&#62;&#60;/li&#62;
 &#60;li&#62;&#60;a href=&#8221;#&#8221;&#62;html5&#60;/a&#62;&#60;/li&#62;
 &#60;li&#62;&#60;a href=&#8221;#&#8221;&#62;css3&#60;/a&#62;&#60;/li&#62;
 &#60;li&#62;&#60;a href=&#8221;#&#8221;&#62;WordPress&#60;/a&#62;&#60;/li&#62;
 &#60;/ul&#62;
 &#60;/div&#62;&#60;!&#8211;  close menu &#8211;&#62;
 &#60;/div&#62;&#60;!&#8211; close navi &#8211;&#62;

这是一个菜单列表，结构上很简单，跟一般的菜单结构类似。
二、使用css3构建华丽菜单
接下来我们需要用到css3的知识来实现如demo上的菜单效果。
完整代码如下：

#navi {
 height: 50px;
 margin-top: 50px;
 font-size:14px;
}

#menu {
 /*背景*/
 background: -webkit-gradient(linear, left top, left bottom,  color-stop(0%,#8AB9EB),  color-stop(40%,#5C9DDC),  color-stop(100%,#2374C5));
 background: [...]]]></description>
			<content:encoded><![CDATA[<p><img title="css3-menu" src="http://images.uheed.com/iwanna/2010/07/02/css3-menu.png" alt="" width="600" height="98" /></p>
<ul>
<li><a title="查看示例" href="http://www.iwanna.cn/examples/css/css3-menu/">查看示例</a></li>
<li><a title="点此下载" href="http://www.iwanna.cn/examples/css/css3-menu/css3-menu.rar">点此下载</a></li>
</ul>
<p>效果说明：当你滚动页面的时候，菜单会放大，固定于头部一起滚动。</p>
<h2>制作教程</h2>
<h4>一、创建如下的菜单结构</h4>
<p><span id="more-4328"></span></p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>&lt;div id=&#8221;navi&#8221;&gt;</li>
<li> &lt;div id=&#8221;<a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>&#8221; class=&#8221;default&#8221;&gt;</li>
<li> &lt;ul&gt;</li>
<li> &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;首页&lt;/a&gt;&lt;/li&gt;</li>
<li> &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>&lt;/a&gt;&lt;/li&gt;</li>
<li> &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;设计&lt;/a&gt;&lt;/li&gt;</li>
<li> &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;flex&lt;/a&gt;&lt;/li&gt;</li>
<li> &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;air&lt;/a&gt;&lt;/li&gt;</li>
<li> &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;<a href="http://www.iwanna.cn/tags/ajax/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Ajax">ajax</a>&lt;/a&gt;&lt;/li&gt;</li>
<li> &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;html5&lt;/a&gt;&lt;/li&gt;</li>
<li> &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;css3&lt;/a&gt;&lt;/li&gt;</li>
<li> &lt;li&gt;&lt;a href=&#8221;#&#8221;&gt;WordPress&lt;/a&gt;&lt;/li&gt;</li>
<li> &lt;/ul&gt;</li>
<li> &lt;/div&gt;&lt;!&#8211;  close <a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a> &#8211;&gt;</li>
<li> &lt;/div&gt;&lt;!&#8211; close navi &#8211;&gt;</li>
</ol>
<p>这是一个菜单列表，结构上很简单，跟一般的菜单结构类似。</p>
<h4>二、使用css3构建华丽菜单</h4>
<p>接下来我们需要用到css3的知识来实现如demo上的菜单效果。<br />
完整代码如下：</p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>#navi {</li>
<li> height: 50px;</li>
<li> margin-top: 50px;</li>
<li> font-size:14px;</li>
<li>}</li>
<li></li>
<li>#<a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a> {</li>
<li> /*背景*/</li>
<li> background: -webkit-gradient(linear, left top, left bottom,  color-stop(0%,#8AB9EB),  color-stop(40%,#5C9DDC),  color-stop(100%,#2374C5));</li>
<li> background: -moz-linear-gradient(top, #8AB9EB, #5C9DDC,  #2374C5);</li>
<li> /*圆角*/</li>
<li> border-radius: 5px;</li>
<li> -webkit-border-radius: 5px;</li>
<li> -moz-border-radius: 5px;</li>
<li> line-height: 50px;</li>
<li> text-align: center;</li>
<li> margin: 0 auto;</li>
<li> padding: 0;</li>
<li>}</li>
<li></li>
<li></li>
<li>ul {</li>
<li> padding: 0;</li>
<li>}</li>
<li></li>
<li>ul li {</li>
<li> list-style-type: none;</li>
<li> display: inline;</li>
<li> margin-right: 15px;</li>
<li>}</li>
<li></li>
<li>ul li a {</li>
<li> color: #fff;</li>
<li> text-decoration: none;</li>
<li> /*文字阴影*/</li>
<li> text-shadow: 1px 1px 1px #000;</li>
<li> padding: 6px 12px;</li>
<li> /*圆角*/</li>
<li> border-radius: 5px;</li>
<li> -webkit-border-radius: 5px;</li>
<li> -moz-border-radius: 5px;</li>
<li></li>
<li> -webkit-transition-property: color, background;</li>
<li> -webkit-transition-duration: 0.5s, 0.5s;</li>
<li>}</li>
<li></li>
<li>ul li a:hover {</li>
<li> background:#FFC;</li>
<li> color:#333;</li>
<li></li>
<li> -webkit-transition-property: color, background;</li>
<li> -webkit-transition-duration: 0.5s, 0.5s;</li>
<li>}</li>
<li></li>
<li>.default {</li>
<li> width: 850px;</li>
<li> height: 50px;</li>
<li></li>
<li> box-shadow: 0 5px 20px #888;</li>
<li> -webkit-box-shadow: 0 5px 20px #888;</li>
<li> -moz-box-shadow: 0 5px 20px #888;</li>
<li>}</li>
<li></li>
<li>.fixed {</li>
<li> position: fixed;</li>
<li> top: -5px;</li>
<li> left: 0;</li>
<li> width: 100%;</li>
<li></li>
<li> box-shadow: 0 0 40px #222;</li>
<li> -webkit-box-shadow: 0 0 40px #222;</li>
<li> -moz-box-shadow: 0 0 40px #222;</li>
<li>}</li>
</ol>
<p>关键部分代码说明<br />
<strong>1、给菜单添加渐变背景</strong></p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>/*背景*/</li>
<li> background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#8AB9EB), color-stop(40%,#5C9DDC), color-stop(100%,#2374C5));</li>
<li> background: -moz-linear-gradient(top, #8AB9EB, #5C9DDC, #2374C5);</li>
</ol>
<p>webkit和firefox在渐变背景的使用上有出入，语法并不相同，firefox更简洁，webkit更符合标准。接下来明河详细说明下这些 参数是什么意思。<br />
先来看firefox的语法：</p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>background: -moz-linear-gradient(top, #8AB9EB, #5C9DDC, #2374C5);</li>
</ol>
<p>这里有四个参数，含义如下：</p>
<ul>
<li>第一个参数，渐变的起始点，这里用到了简写，本来应该是 left top，火狐可以只用left，top是默认的，也就是至上向下。</li>
<li>第二个参数，起始渐变色</li>
<li>第三个参数，中间渐变色</li>
<li>第四个参数，终点渐变色</li>
</ul>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#8AB9EB), color-stop(40%,#5C9DDC), color-stop(100%,#2374C5));</li>
</ol>
<p>webkit的参数比较多，含义如下：</p>
<ul>
<li>linear 线性渐变</li>
<li>left top起始位置</li>
<li>left bottom终点位置</li>
<li>color-stop(0%,#8AB9EB)起始颜色</li>
<li>color-stop(40%,#5C9DDC)中间颜色</li>
<li>color-stop(100%,#2374C5)终点颜色</li>
</ul>
<p>关于渐变背景的详细说明请<a href="http://www.qianduan.net/understand-the-css3-gradient.html">点此</a>。<br />
<strong>2、给菜单容器添加圆角</strong></p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>/*圆角*/</li>
<li> border-radius: 5px;</li>
<li> -webkit-border-radius: 5px;</li>
<li> -moz-border-radius: 5px;</li>
</ol>
<p>这个很简单，明河就不说明了<br />
<strong>3、给菜单项加入如下样式</strong></p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>ul li a {</li>
<li> color: #fff;</li>
<li> text-decoration: none;</li>
<li> /*文字阴影*/</li>
<li> text-shadow: 1px 1px 1px #000;</li>
<li> padding: 6px 12px;</li>
<li> /*圆角*/</li>
<li> border-radius: 5px;</li>
<li> -webkit-border-radius: 5px;</li>
<li> -moz-border-radius: 5px;</li>
<li></li>
<li> -webkit-transition-property: color, background;</li>
<li> -webkit-transition-duration: 0.5s, 0.5s;</li>
<li>}</li>
</ol>
<p>留意这里的文字阴影的用法。</p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>-webkit-transition-property:  color, background;</li>
<li> -webkit-transition-duration: 0.5s, 0.5s;</li>
</ol>
<p>只适用于webkit浏览器，是控制背景透明度。</p>
<h4>三、使用<a href="http://www.iwanna.cn/tags/jquery/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with JQuery">jquery</a>让菜单跟随页面滚动</h4>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(function(){</li>
<li> var <a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a> = $(&#8216;#<a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>&#8217;),</li>
<li> pos = <a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>.offset();</li>
<li></li>
<li> $(window).scroll(function(){</li>
<li> if($(this).scrollTop() &gt; pos.top+<a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>.height() &amp;&amp; <a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>.hasClass(&#8216;default&#8217;)){</li>
<li> <a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>.fadeOut(&#8216;fast&#8217;, function(){</li>
<li> $(this).removeClass(&#8216;default&#8217;).addClass(&#8216;fixed&#8217;).fadeIn(&#8216;fast&#8217;);</li>
<li> });</li>
<li> } else if($(this).scrollTop() &lt;= pos.top &amp;&amp; <a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>.hasClass(&#8216;fixed&#8217;)){</li>
<li> <a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>.fadeOut(&#8216;fast&#8217;, function(){</li>
<li> $(this).removeClass(&#8216;fixed&#8217;).addClass(&#8216;default&#8217;).fadeIn(&#8216;fast&#8217;);</li>
<li> });</li>
<li> }</li>
<li> });</li>
<li>})</li>
</ol>
<p>关键代码说明：</p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>pos = <a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>.offset();</li>
</ol>
<p>offset()获取菜单在当前页面的位置，返回的是一个object:{top:”XXpx”,left:”XXpx”}。</p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(window).scroll(function(){</li>
<li>&#8230;&#8230;..</li>
<li>});</li>
</ol>
<p>监听窗体的滚动事件。</p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(this).scrollTop()</li>
</ol>
<p>scrollTop()将得到滚动条的滚动距离，非常重要的一个值。</p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>$(this).scrollTop() &gt; pos.top+<a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>.height() &amp;&amp; <a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>.hasClass(&#8216;default&#8217;)</li>
</ol>
<p>根据滚动距离，确定菜单是否还可见，不可见，则改变菜单的定位方式.</p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li><a href="http://www.iwanna.cn/tags/menu/" class="st_tag internal_tag" rel="tag nofollow" title="Posts tagged with Menu">menu</a>.fadeOut(&#8216;fast&#8217;, function(){</li>
<li> $(this).removeClass(&#8216;default&#8217;).addClass(&#8216;fixed&#8217;).fadeIn(&#8216;fast&#8217;);</li>
<li> });</li>
</ol>
<p>给菜单加入了fixed样式：</p>
<ol title="Double click  to hide line number." ondblclick="linenumber(this)">
<li>.fixed {</li>
<li> position: fixed;</li>
<li> top: -5px;</li>
<li> left: 0;</li>
<li> width: 100%;</li>
<li></li>
<li> box-shadow: 0 0 40px #222;</li>
<li> -webkit-box-shadow: 0 0 40px #222;</li>
<li> -moz-box-shadow: 0 0 40px #222;</li>
<li>}</li>
</ol>
<p>有二个关键的点：</p>
<ul>
<li>position: fixed;将其定位方式改变成固定定位</li>
<li>box-shadow ：加入阴影</li>
</ul>
<p>完毕！有问题可以给明河留言谢谢！</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/07/02/4328/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/07/02/4328/#comments">没有评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/07/02/4328/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/07/02/4328/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/07/02/4328/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/css/" title="CSS" rel="tag nofollow">CSS</a>, <a href="http://www.iwanna.cn/tags/css/" title="CSS" rel="tag nofollow">CSS</a>, <a href="http://www.iwanna.cn/topics/ui/javascript/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/jquery/" title="JQuery" rel="tag nofollow">JQuery</a>, <a href="http://www.iwanna.cn/tags/tutorial/" title="Tutorial" rel="tag nofollow">Tutorial</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2009/06/17/1828/" title="用jQuery和CSS构建下拉菜单 (2009年06月17日)">用jQuery和CSS构建下拉菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/27/4767/" title="一个基于JQuery 和CSS3的滑动菜单 (2010年07月27日)">一个基于JQuery 和CSS3的滑动菜单</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/04/30/915/" title="解密CSS Sprites：技巧、工具和教程 (2009年04月30日)">解密CSS Sprites：技巧、工具和教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/06/07/3765/" title="简单的JQuery聚光灯效果教程 (2010年06月7日)">简单的JQuery聚光灯效果教程</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/17/4583/" title="制作jquery文字提示插件 (2010年07月17日)">制作jquery文字提示插件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/24/1129/" title="八种布局方案改善你的设计 (2009年05月24日)">八种布局方案改善你的设计</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/09/4445/" title="jQuery + CSS3 实现图片圆角 (2010年07月9日)">jQuery + CSS3 实现图片圆角</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/06/30/1894/" title="40+ Web前端开发必备的备忘单[上] (2009年06月30日)">40+ Web前端开发必备的备忘单[上]</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/02/20/2527/" title="10个令人惊异的创建按钮的CSS3教程、方法 (2010年02月20日)">10个令人惊异的创建按钮的CSS3教程、方法</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/04/30/2887/" title="10个为Web设计师准备的jQuery教程 (2010年04月30日)">10个为Web设计师准备的jQuery教程</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/07/02/4328/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript性能陷阱</title>
		<link>http://www.iwanna.cn/archives/2010/06/25/4198/</link>
		<comments>http://www.iwanna.cn/archives/2010/06/25/4198/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 15:01:45 +0000</pubDate>
		<dc:creator>seasun</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.iwanna.cn/?p=4198</guid>
		<description><![CDATA[JavaScript陷阱太多，因此我们得步步为营，下面是一些常见的影响性能的陷阱。
1.避免使用eval或者Function构造函数
使用eval或者Function构造函数的代价是非常昂贵的，每次都需要脚本引擎转换源代码到可执行代码。
此外，使用eval处理字符串必须在运行时解释。
运行缓慢的代码：





1
2
3
4



function addMethod(object, property, code) {
	object[property] = new Function(code);
}
addMethod(myObj, 'methodName', 'this.localVar=foo');






运行更快的代码：





1
2
3
4



function addMethod(object, property, func) {
	object[property] = func;
}
addMethod(myObj, 'methodName', function () { 'this.localVar=foo'; });





2.避免使用with
尽管很方便，with需要附加的查找引用时间，因为它在编译的时候并不知道作用域的上下没。
运行缓慢的代码：





1
2
3
4



with (test.object) {
	foo = 'Value of foo property of object';
	bar = 'Value of bar property of object';
}





运行更快的代码：





1
2
3



var myObj = test.object;
myObj.foo = 'Value of foo property of object';
myObj.bar = 'Value of bar property of object';





3.不要在性能要求关键的函数中使用try-catch-finally
try-catch-finally在运行时每次都会在当前作用域创建一个新的变量，用于分配语句执行的异常。
异常处理应该在脚本的高层完成，在异常不是很频繁发生的地方，比如一个循环体的外面。
如果可能，尽量完全避免使用try-catch-finally。
运行缓慢的代码：





1
2
3
4
5
6
7
8



var [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://www.iwanna.cn/archives/2010/06/25/4198/" title="JavaScript性能陷阱">JavaScript陷阱</a></strong>太多，因此我们得步步为营，下面是一些常见的影响性能的陷阱。<br />
<strong>1.避免使用eval或者Function构造函数</strong><br />
使用eval或者Function构造函数的代价是非常昂贵的，每次都需要脚本引擎转换源代码到可执行代码。<br />
此外，使用eval处理字符串必须在运行时解释。</p>
<p>运行缓慢的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
</pre>
</td>
<td>
<pre>function addMethod(object, property, code) {
	object[property] = new Function(code);
}
addMethod(myObj, 'methodName', 'this.localVar=foo');</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><span id="more-4198"></span><br />
运行更快的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
</pre>
</td>
<td>
<pre>function addMethod(object, property, func) {
	object[property] = func;
}
addMethod(myObj, 'methodName', function () { 'this.localVar=foo'; });</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>2.避免使用with</strong><br />
尽管很方便，with需要附加的查找引用时间，因为它在编译的时候并不知道作用域的上下没。</p>
<p>运行缓慢的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
</pre>
</td>
<td>
<pre>with (test.object) {
	foo = 'Value of foo property of object';
	bar = 'Value of bar property of object';
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>运行更快的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
</pre>
</td>
<td>
<pre>var myObj = test.object;
myObj.foo = 'Value of foo property of object';
myObj.bar = 'Value of bar property of object';</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>3.不要在性能要求关键的函数中使用try-catch-finally</strong><br />
try-catch-finally在运行时每次都会在当前作用域创建一个新的变量，用于分配语句执行的异常。<br />
异常处理应该在脚本的高层完成，在异常不是很频繁发生的地方，比如一个循环体的外面。<br />
如果可能，尽量完全避免使用try-catch-finally。</p>
<p>运行缓慢的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
5
6
7
8
</pre>
</td>
<td>
<pre>var object = ['foo', 'bar'], i;
for (i = 0; i &lt; object.length; i++) {
	try {
		// do something that throws an exception
	} catch (e) {
		// handle exception
	}
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>运行更快的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
5
6
7
8
</pre>
</td>
<td>
<pre>var object = ['foo', 'bar'], i;
try {
	for (i = 0; i &lt; object.length; i++) {
		// do something
	}
} catch (e) {
	// handle exception
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>4.避免使用全局变量</strong><br />
如果你在一个函数或者其它作用域中使用全局变量，脚本引擎需要遍历整个作用域去查找他们。<br />
全局作用域中的变量在脚本的生命周期里都存在，然后局部范围的会在局部范围失去的时候被销毁。</p>
<p>运行缓慢的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
5
6
7
8
</pre>
</td>
<td>
<pre>var i,
str = '';
function globalScope() {
	for (i=0; i &lt; 100; i++) {
		str += i; // here we reference i and str in global scope which is slow
	}
}
globalScope();</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>运行更快的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
5
6
7
8
</pre>
</td>
<td>
<pre>function localScope() {
	var i,
	str = '';
	for (i=0; i &lt; 100; i++) {
		str += i; // i and str in local scope which is faster
	}
}
localScope();</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>5.避免在性能要求关键的函数中使用for-in</strong><br />
for-in循环需要脚本引擎建立一张所有可枚举属性的列表，并检查是否与先前的重复。<br />
如果你的for循环作用域中的代码没有修改数组，可以预先计算好数组的长度用于在for循环中迭代数组。</p>
<p>运行缓慢的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
</pre>
</td>
<td>
<pre>var sum = 0;
for (var i in arr) {
	sum += arr[i];
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>运行更快的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
</pre>
</td>
<td>
<pre>var sum = 0;
for (var i = 0, len = arr.length; i &lt; len; i++) {
	sum += arr[i];
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>6.使用字符串累加计算风格</strong><br />
使用+运算会在内存中创建一个新的字符串并把连接的值赋给它。仅仅是将这个结果赋值给一个变量。<br />
为了避免连接结果的中间变量，可以使用+=来直接赋值结果。</p>
<p>运行缓慢的代码：</p>
<div>
<div>
<pre>a += 'x' + 'y';</pre>
</div>
</div>
<p>运行更快的代码：</p>
<div>
<div>
<pre>a += 'x'; a += 'y';</pre>
</div>
</div>
<p><strong>7.原操作会比函数调用快</strong><br />
可以考虑在性能要求关键的循环和函数中使用可以替代的原操作。<br />
运行缓慢的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
</pre>
</td>
<td>
<pre>var min = Math.min(a, b);
arr.push(val);</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>运行更快的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
</pre>
</td>
<td>
<pre>var min = a &lt; b ? a : b;
arr[arr.length] = val;</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>8.设置setTimeout() 和 setInterval() 时传递函数名而不是字符串</strong><br />
如果你传递一个字符串到setTimeout() 或者 setInterval()中，字符串将会被eval计算而导致缓慢。<br />
使用一个匿名函数包装来代替，这样在编译的时候就可以被解释和优化。</p>
<p>运行缓慢的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
</pre>
</td>
<td>
<pre>setInterval('doSomethingPeriodically()', 1000);
setTimeOut('doSomethingAfterFiveSeconds()', 5000);</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>运行更快的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
</pre>
</td>
<td>
<pre>setInterval(doSomethingPeriodically, 1000);
setTimeOut(doSomethingAfterFiveSeconds, 5000);</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>9.避免在对象中使用不需要的DOM引用</strong></p>
<p>不要这么做：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
</pre>
</td>
<td>
<pre>var car = new Object();
car.color = "red";
car.type = "sedan"</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>更好的一种形式：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
</pre>
</td>
<td>
<pre>var car = {
	color : "red";
	type : "sedan"
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>10.最清晰的目标速度，最小化作用域链</strong></p>
<p>低效率方法：</p>
<div>
<div>
<pre>var url = location.href;</pre>
</div>
</div>
<p>一种高效形式：</p>
<div>
<div>
<pre>var url = window.location.href;</pre>
</div>
</div>
<p><strong>11.试着在脚本中少使用注释，避免使用长变量名</strong><br />
尽可能的保证注释少或者避免使用注释，特别是在函数，循环以及数组中。<br />
注释不必要的减缓脚本执行并且增加了文件大小。比如：</p>
<p>不建议的形式：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
</pre>
</td>
<td>
<pre>function someFunction()
{
	var person_full_name="somename"; /* stores the full name*/
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>更好的写法：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
</pre>
</td>
<td>
<pre>function someFunction()
{
	var name="somename";
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>12.在当前作用域存储应用的外部变量</strong><br />
当一个函数被执行的运行上下问被穿件，一个活动的对象会包含所有局部变量会被推到上下文链的前面。<br />
在作用域链中，最慢的是清楚的识别标识符，意味着局部变量是最快的。存储频繁使用的外部变量读和写都会明显的加快。这对于全局变量和其他深层次的标识符查 找特别明显。<br />
同样，在当前作用域中的变量(var myVar)比对象像属性的访问速度快(this.myVar)。</p>
<p>运行缓慢的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
5
6
7
</pre>
</td>
<td>
<pre>function doSomething(text) {
	var divs = document.getElementsByTagName('div'),
		text = ['foo', /* ... n ... */, 'bar'];
	for (var i = 0, l = divs.length; i &lt; l; i++) {
		divs[i].innerHTML = text[i];
	}
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>运行更快的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
5
6
7
8
</pre>
</td>
<td>
<pre>function doSomethingFaster(text) {
	var doc = document,
		divs = doc.getElementsByTagName('div'),
		text = ['foo', /* ... n ... */, 'bar'];
	for (var i = 0, l = divs.length; i &lt; l; i++) {
		divs[i].innerHTML = text[i];
	}
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>如果你需要访问一个元素（如 head）在一个大的循环中，使用一个本地的DOM访问(如例子中的get)会更快。<br />
运行更快的代码：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
5
6
</pre>
</td>
<td>
<pre>function doSomethingElseFaster() {
	var get = document.getElementsByTagName;
	for (var i = 0, i &lt; 100000; i++) {
		get('head');
	}
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p><strong>13.使用变量缓存值</strong><br />
在做重复工作的地方使用局部变量缓存值。<br />
下面的一组例子表明了存储值到局部变量的广泛意义。</p>
<p>例子1.计算执行前在循环体内使用变量存储数学函数<br />
错误的方法：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
</pre>
</td>
<td>
<pre>var d=35;
for (var i=0; i&lt;1000; i++) {
	y += Math.sin(d)*10;
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>更好的处理：</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
4
5
</pre>
</td>
<td>
<pre>var d = 55;
var math_sind = Math.sin(d)*10;
for (var i=0; i&lt;1000; i++) {
	y += math_sind;
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>例子2.保存数组的长度在循环中使用<br />
糟糕的处理:<br />
数组的长度每次都会被重复计算</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
</pre>
</td>
<td>
<pre>for (var i = 0; i &lt; arr.length; i++) {
	// do something
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>更好的改进：<br />
更好的方法是保存数组的长度</p>
<div>
<table>
<tbody>
<tr>
<td>
<pre>1
2
3
</pre>
</td>
<td>
<pre>for (var i = 0, len = arr.length; i &lt; len; i++) {
	// do something
}</pre>
</td>
</tr>
</tbody>
</table>
</div>
<p>总的来说，如果已经做了一次，我们就不需要重复的做不必要的工作。例如，作用域或者函数中多次使用到计算的一个表达式的值，保存到变量可以使它多次 被使用，否则我们会过头的声明一个变量并赋值然后只适用一次。所以请记住这些。</p>
<hr />
<p>© <a href="http://www.iwanna.cn">我想网</a> Akon 所有 , 2010. |
<a href="http://www.iwanna.cn/archives/2010/06/25/4198/">永久链接</a> |
<a href="http://www.iwanna.cn/archives/2010/06/25/4198/#comments">1条评论</a> |
提交到
<a rel="nofollow" target="_blank" href="http://www.google.com/reader/view/feed/http://www.iwanna.cn/archives/2010/06/25/4198/">Google Reader</a>
<a rel="nofollow" target="_blank" href="http://www.xianguo.com/subscribe.php?url=http://www.iwanna.cn/archives/2010/06/25/4198/">鲜果</a>
<a rel="nofollow" target="_blank" href="http://www.zhuaxia.com/add_channel.php?url=http://www.iwanna.cn/archives/2010/06/25/4198/">抓虾</a>
<hr />
</p>
	标签：<a href="http://www.iwanna.cn/topics/ui/javascript/" title="JavaScript" rel="tag nofollow">JavaScript</a>, <a href="http://www.iwanna.cn/tags/javascript/" title="JavaScript" rel="tag nofollow">JavaScript</a><br />

	<h2 class="related_post">您可能会感兴趣的其他文章</h2>
	<ul class="st-related-posts">
	<li><a href="http://www.iwanna.cn/archives/2009/04/29/894/" title="页面输出时一些常用的小技巧 (2009年04月29日)">页面输出时一些常用的小技巧</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/03/31/79/" title="表单元素：40个CSS/JS风格和功能技术处理 (2009年03月31日)">表单元素：40个CSS/JS风格和功能技术处理</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/06/4383/" title="网页打开新窗口的解决方案,拒绝屏蔽 (2010年07月6日)">网页打开新窗口的解决方案,拒绝屏蔽</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/04/29/2874/" title="相见恨晚的一些 JavaScript 技巧 (2010年04月29日)">相见恨晚的一些 JavaScript 技巧</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/09/18/2252/" title="用JS制作的网页版NES模拟器 IE8直接出局 (2009年09月18日)">用JS制作的网页版NES模拟器 IE8直接出局</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/03/31/77/" title="用css+js控制图片大小的方法 (2009年03月31日)">用css+js控制图片大小的方法</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/02/17/2516/" title="有关 JavaScript 的 10 件让人费解的事情 (2010年02月17日)">有关 JavaScript 的 10 件让人费解的事情</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/11/29/2396/" title="新 API 寻求让 JavaScript 操作本地文件 (2009年11月29日)">新 API 寻求让 JavaScript 操作本地文件</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2009/05/17/1085/" title="并发下载javascript (2009年05月17日)">并发下载javascript</a> </li>
	<li><a href="http://www.iwanna.cn/archives/2010/07/13/4521/" title="常用JS验证函数总结 (2010年07月13日)">常用JS验证函数总结</a> </li>
</ul>


<p><small>Feed enhanced by <a href='http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/'>Better Feed</a> from  <a href='http://planetozh.com/blog/'>Ozh</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.iwanna.cn/archives/2010/06/25/4198/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
