<?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>前端思考：专注前端开发，关注用户体验</title>
	<atom:link href="http://www.artcss.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.artcss.com</link>
	<description>一个像素的距离...</description>
	<lastBuildDate>Sun, 15 Aug 2010 05:41:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>浏览器兼容手册[总结]</title>
		<link>http://www.artcss.com/archives/850.html</link>
		<comments>http://www.artcss.com/archives/850.html#comments</comments>
		<pubDate>Tue, 27 Jul 2010 09:04:13 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[默认]]></category>

		<guid isPermaLink="false">http://www.artcss.com/?p=850</guid>
		<description><![CDATA[这是我总结多年的一个小文档，最近看见有人咨询浏览器兼容的问题，就贡献出来。 并不一定全，有的也可能不准确，比如新出的IE8、Chrome等都没有太多涉及，虽然最近做的一些项目也兼容了IE8、Chrome等，但都没来的及总结进去，后来就忘了&#8230;汗。大家一起慢慢完善吧。 javascript部分 1. document.form.item 问题 问题： 代码中存在 document.formName.item(&#8220;itemName&#8221;) 这样的语句，不能在FF下运行 解决方法： 改用 document.formName.elements["elementName"] 2. 集合类对象问题 问题： 代码中许多集合类对象取用时使用()，IE能接受，FF不能 解决方法： 改用 [] 作为下标运算，例： document.getElementsByName(&#8220;inputName&#8221;)(1) 改为 document.getElementsByName(&#8220;inputName&#8221;)[1] 3. window.event 问题： 使用 window.event 无法在FF上运行 解决方法： FF的 event 只能在事件发生的现场使用，此问题暂无法解决。可以把 event 传到函数里变通解决： onMouseMove = &#8220;functionName(event)&#8221; function functionName (e) { &#160; &#160; e = e &#124;&#124; window.event; &#160; &#160; &#8230;&#8230; } 4. [...]]]></description>
			<content:encoded><![CDATA[<p>这是我总结多年的一个小文档，最近看见有人咨询浏览器兼容的问题，就贡献出来。</p>
<p>
并不一定全，有的也可能不准确，比如新出的IE8、Chrome等都没有太多涉及，虽然最近做的一些项目也兼容了IE8、Chrome等，但都没来的及总结进去，后来就忘了&#8230;汗。大家一起慢慢完善吧。</p>
<p><strong><font color="Navy">javascript部分</font></strong></p>
<p><strong>1. document.form.item 问题</strong><br />
问题：<br />
代码中存在 document.formName.item(&#8220;itemName&#8221;) 这样的语句，不能在FF下运行<br />
解决方法：<br />
改用 document.formName.elements["elementName"]</p>
<p><strong>2. 集合类对象问题</strong><br />
问题：<br />
代码中许多集合类对象取用时使用()，IE能接受，FF不能<br />
解决方法：<br />
改用 [] 作为下标运算，例：<br />
document.getElementsByName(&#8220;inputName&#8221;)(1) 改为 document.getElementsByName(&#8220;inputName&#8221;)[1]</p>
<p><strong>3. window.event</strong><br />
问题：<br />
使用 window.event 无法在FF上运行<br />
解决方法：<br />
FF的 event 只能在事件发生的现场使用，此问题暂无法解决。可以把 event 传到函数里变通解决：<br />
onMouseMove = &#8220;functionName(event)&#8221;<br />
function functionName (e) {<br />
&nbsp; &nbsp; e = e || window.event;<br />
&nbsp; &nbsp; &#8230;&#8230;<br />
}</p>
<p><strong>4. HTML对象的 id 作为对象名的问题</strong><br />
问题：<br />
在IE中，HTML对象的 ID 可以作为 document 的下属对象变量名直接使用，在FF中不能<br />
解决方法：<br />
使用对象变量时全部用标准的 getElementById(&#8220;idName&#8221;)</p>
<p><strong>5. 用 idName 字符串取得对象的问题</strong><br />
问题：<br />
在IE中，利用 eval(&#8220;idName&#8221;) 可以取得 id 为 idName 的HTML对象，在FF中不能<br />
解决方法：<br />
用 getElementById(&#8220;idName&#8221;) 代替 eval(&#8220;idName&#8221;)</p>
<p><strong>6. 变量名与某HTML对象 id 相同的问题</strong><br />
问题：<br />
在FF中，因为对象 id 不作为HTML对象的名称，所以可以使用与HTML对象 id 相同的变量名，IE中不能<br />
解决方法：<br />
在声明变量时，一律加上 var ，以避免歧义，这样在IE中亦可正常运行<br />
最好不要取与HTML对象 id 相同的变量名，以减少错误</p>
<p><strong>7. event.x 与 event.y 问题</strong><br />
问题：<br />
在IE中，event 对象有x,y属性，FF中没有<br />
解决方法：<br />
在FF中，与 event.x 等效的是 event.pageX ，但event.pageX IE中没有<br />
故采用 event.clientX 代替 event.x ，在IE中也有这个变量<br />
event.clientX 与 event.pageX 有微妙的差别，就是滚动条<br />
要完全一样，可以这样：<br />
mX = event.x ? event.x : event.pageX;<br />
然后用 mX 代替 event.x</p>
<p><strong>8. 关于frame</strong><br />
问题：<br />
在IE中可以用 window.testFrame 取得该frame，FF中不行<br />
解决方法：<br />
window.top.document.getElementById(&#8220;testFrame&#8221;).src = &#8216;xx.htm&#8217;<br />
window.top.frameName.location = &#8216;xx.htm&#8217;</p>
<p><strong>9. 取得元素的属性</strong><br />
在FF中，自己定义的属性必须 getAttribute() 取得</p>
<p><strong>10. 在FF中没有 parentElement，parement.children 而用 parentNode，parentNode.childNodes</strong><br />
问题：<br />
childNodes 的下标的含义在IE和FF中不同，FF的 childNodes 中会插入空白文本节点<br />
解决方法：<br />
可以通过 node.getElementsByTagName() 来回避这个问题<br />
问题：<br />
当html中节点缺失时，IE和FF对 parentNode 的解释不同，例如：<br />
&lt;form&gt;<br />
&lt;table&gt;<br />
&lt;input/&gt;<br />
&lt;/table&gt;<br />
&lt;/form&gt;<br />
FF中 input.parentNode 的值为form，而IE中 input.parentNode 的值为空节点<br />
问题：<br />
FF中节点自己没有 removeNode 方法<br />
解决方法：<br />
必须使用如下方法 node.parentNode.removeChild(node)</p>
<p><strong>11. const 问题</strong><br />
问题：<br />
在IE中不能使用 const 关键字<br />
解决方法：<br />
以 var 代替</p>
<p><strong>12. body 对象</strong><br />
FF的 body 在 body 标签没有被浏览器完全读入之前就存在，而IE则必须在 body 完全被读入之后才存在<br />
这会产生在IE下，文档没有载入完时，在body上appendChild会出现空白页面的问题<br />
解决方法：<br />
一切在body上插入节点的动作，全部在onload后进行</p>
<p><strong>13. url encoding</strong><br />
问题：<br />
一般FF无法识别js中的&amp;<br />
解决方法：<br />
在js中如果书写url就直接写&amp;不要写&amp;</p>
<p><strong>14. nodeName 和 tagName 问题</strong><br />
问题：<br />
在FF中，所有节点均有 nodeName 值，但 textNode 没有 tagName 值，在IE中，nodeName 的使用有问题<br />
解决方法：<br />
使用 tagName，但应检测其是否为空</p>
<p><strong>15. 元素属性</strong><br />
IE下 input.type 属性为只读，但是FF下可以修改</p>
<p><strong>16. document.getElementsByName() 和 document.all[name] 的问题</strong><br />
问题：<br />
在IE中，getElementsByName()、document.all[name] 均不能用来取得 div 元素<br />
是否还有其它不能取的元素还不知道（这个问题还有争议，还在研究中）</p>
<p><strong>17. 调用子框架或者其它框架中的元素的问题</strong><br />
在IE中，可以用如下方法来取得子元素中的值<br />
document.getElementById(&#8220;frameName&#8221;).(document.)elementName<br />
window.frames["frameName"].elementName<br />
在FF中则需要改成如下形式来执行，与IE兼容：<br />
window.frames["frameName"].contentWindow.document.elementName<br />
window.frames["frameName"].document.elementName</p>
<p><strong>18. 对象宽高赋值问题</strong><br />
问题：<br />
FireFox中类似 obj.style.height = imgObj.height 的语句无效<br />
解决方法：<br />
统一使用 obj.style.height = imgObj.height + &#8220;px&#8221;;</p>
<p><strong>19. innerText的问题</strong><br />
问题：<br />
innerText 在IE中能正常工作，但是 innerText 在FireFox中却不行<br />
解决方法：<br />
在非IE浏览器中使用textContent代替innerText</p>
<p><strong>20. event.srcElement和event.toElement问题</strong><br />
问题：<br />
IE下，even对象有srcElement属性，但是没有target属性；Firefox下，even对象有target属性，但是没有srcElement属性<br />
解决方法：<br />
var source = e.target || e.srcElement;<br />
var target = e.relatedTarget || e.toElement;</p>
<p><strong>21. 禁止选取网页内容</strong><br />
问题：<br />
FF需要用CSS禁止，IE用JS禁止<br />
解决方法：<br />
IE: obj.onselectstart = function() {return false;}<br />
FF: -moz-user-select:none;</p>
<p><strong>22. 捕获事件</strong><br />
问题：<br />
FF没有setCapture()、releaseCapture()方法<br />
解决方法：<br />
IE:<br />
obj.setCapture(); <br />
obj.releaseCapture();<br />
FF:<br />
window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);<br />
window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);<br />
if (!window.captureEvents) {<br />
&nbsp; &nbsp; &nbsp; &nbsp;o.setCapture();<br />
}else {<br />
&nbsp; &nbsp; &nbsp; &nbsp;window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);<br />
}<br />
if (!window.captureEvents) {<br />
&nbsp; &nbsp; &nbsp; &nbsp;o.releaseCapture();<br />
}else {<br />
&nbsp; &nbsp; &nbsp; &nbsp;window.releaseEvents(Event.MOUSEMOVE|Event.MOUSEUP);<br />
}</p>
<p>
<strong><font color="Navy">CSS部分</font></strong></p>
<p><strong>div类</strong></p>
<p><strong>1. 居中问题</strong><br />
div里的内容，IE默认为居中，而FF默认为左对齐<br />
可以尝试增加代码margin:auto</p>
<p><strong>2. 高度问题</strong><br />
两上下排列或嵌套的div，上面的div设置高度(height)，如果div里的实际内容大于所设高度，在FF中会出现两个div重叠的现象；但在IE中，下面的div会自动给上面的div让出空间<br />
所以为避免出现层的重叠，高度一定要控制恰当，或者干脆不写高度，让他自动调节，比较好的方法是 height:100%;<br />
但当这个div里面一级的元素都float了的时候，则需要在div块的最后，闭和前加一个沉底的空div，对应CSS是：<br />
.float_bottom {clear:both;height:0px;font-size:0px;padding:0;margin:0;border:0;line-height:0px;overflow:hidden;}</p>
<p><strong>3. clear:both;</strong><br />
不想受到float浮动的，就在div中写入clear:both;</p>
<p><strong>4. IE浮动 margin 产生的双倍距离</strong><br />
#box {<br />
float:left;<br />
width:100px;<br />
margin:0 0 0 100px; //这种情况之下IE会产生200px的距离<br />
display:inline; //使浮动忽略<br />
}</p>
<p><strong>5. padding 问题</strong><br />
FF设置 padding 后，div会增加 height 和 width，但IE不会 （* 标准的 XHTML1.0 定义 dtd 好像一致了）<br />
高度控制恰当，或尝试使用 height:100%;<br />
宽度减少使用 padding<br />
但根据实际经验，一般FF和IE的 padding 不会有太大区别，div 的实际宽 = width + padding ，所以div写全 width 和 padding，width 用实际想要的宽减去 padding 定义</p>
<p><strong>6. div嵌套时 y 轴上 padding 和 marign 的问题</strong><br />
FF里 y 轴上 子div 到 父div 的距离为 父padding + 子marign<br />
IE里 y 轴上 子div 到 父div 的距离为 父padding 和 子marign 里大的一个<br />
FF里 y 轴上 父padding=0 且 border=0 时，子div 到 父div 的距离为0，子marign 作用到 父div 外面</p>
<p><strong>7. padding，marign，height，width 的傻瓜式解决技巧</strong><br />
注意是技巧，不是方法：<br />
写好标准头<br />
&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;<br />
&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221;&gt;<br />
高尽量用padding，慎用margin，height尽量补上100%，父级height有定值子级height不用100%，子级全为浮动时底部补个空clear:both的div<br />
宽尽量用margin，慎用padding，width算准实际要的减去padding</p>
<p><strong>列表类</strong></p>
<p><strong>1. ul 标签在FF中默认是有 padding 值的，而在IE中只有margin有值</strong><br />
先定义 ul {margin:0;padding:0;}</p>
<p><strong>2. ul和ol列表缩进问题</strong><br />
消除ul、ol等列表的缩进时，样式应写成: {list-style:none;margin:0px;padding:0px;}</p>
<p><strong>显示类</strong></p>
<p><strong>1. display:block,inline 两个元素</strong><br />
display:block; //可以为内嵌元素模拟为块元素<br />
display:inline; //实现同一行排列的的效果<br />
display:table; //for FF,模拟table的效果<br />
display:block 块元素，元素的特点是：<br />
总是在新行上开始；<br />
高度，行高以及顶和底边距都可控制；<br />
宽度缺省是它的容器的100%，除非设定一个宽度<br />
&lt;div&gt;，&lt;p&gt;，&lt;h1&gt;，&lt;form&gt;，&lt;ul&gt; 和 &lt;li&gt; 是块元素的例子<br />
display:inline 就是将元素显示为行内元素，元素的特点是：<br />
和其他元素都在一行上；<br />
高，行高及顶和底边距不可改变；<br />
宽度就是它的文字或图片的宽度，不可改变。<br />
&lt;span&gt;，&lt;a&gt;，&lt;label&gt;，&lt;input&gt;，&lt;img&gt;，&lt;strong&gt; 和 &lt;em&gt; 是 inline 元素的例子</p>
<p><strong>2. 鼠标手指状显示</strong><br />
全部用标准的写法 cursor: pointer; </p>
<p><strong>背景、图片类</strong></p>
<p><strong>1. background 显示问题</strong><br />
全部注意补齐 width，height 属性</p>
<p><strong>2. 背景透明问题</strong><br />
IE: filter: progid: DXImageTransform.Microsoft.Alpha(style=0,opacity=60);<br />
IE: filter: alpha(opacity=10);<br />
FF: opacity:0.6;<br />
FF: -moz-opacity:0.10;<br />
最好两个都写，并将opacity属性放在下面</p>
<p>【转自】：蓝色理想论坛 作者：zaku<br />
  原帖链接：<a href="http://bbs.blueidea.com/thread-2941700-1-2.html" target="_blank">http://bbs.blueidea.com/thread-2941700-1-2.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/850.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>仿校内textarea输入框字数限制效果</title>
		<link>http://www.artcss.com/archives/831.html</link>
		<comments>http://www.artcss.com/archives/831.html#comments</comments>
		<pubDate>Wed, 09 Jun 2010 16:42:18 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[个人随笔]]></category>

		<guid isPermaLink="false">http://www.artcss.com/?p=831</guid>
		<description><![CDATA[这是一个仿校内textarea回复消息输入框限制字数的效果，具体表现如下： 普通状态是一个输入框，当光标获取焦点时，出现字数记录和回复按钮 PS:上边那个小三角可不是用的图片。 普通状态效果如下： 获取焦点时： 字数限制的javascript代码如下: Download oTab.js1 2 3 4 5 6 7 8 $&#40;function&#40;&#41;&#123; function maxLimit&#40;&#41;&#123; var num=$&#40;this&#41;.val&#40;&#41;.substr&#40;0,140&#41;; $&#40;this&#41;.val&#40;num&#41;; $&#40;this&#41;.next&#40;&#41;.children&#40;&#34;span&#34;&#41;.text&#40;$&#40;this&#41;.val&#40;&#41;.length+&#34;/140&#34;&#41;; &#125;; $&#40;&#34;#textlimit&#34;&#41;.keyup&#40;maxLimit&#41;;//调用方法 &#125;&#41;; 点击下面“运行”直接查看效果 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34;&#62; &#60;meta name=&#34;author&#34; content=&#34;Web Layout:LiQiang.Gu;&#34; /&#62; &#60;meta name=&#34;description&#34; content=&#34;前端思考 web前端 前端制作 artskin www.artcss.com&#34; /&#62; &#60;meta [...]]]></description>
			<content:encoded><![CDATA[<p>这是一个仿校内textarea回复消息输入框限制字数的效果，具体表现如下：</p>
<p>普通状态是一个输入框，当光标获取焦点时，出现字数记录和回复按钮</p>
<p>PS:<span class="red">上边那个小三角可不是用的图片。</span></p>
<p>普通状态效果如下：<br /><a href="http://www.artcss.com/wp-content/uploads/2010/06/input.png"><img src="http://www.artcss.com/wp-content/uploads/2010/06/input.png" alt="" title="input" width="445" height="71" class="alignnone size-full wp-image-832" /></a></p>
<p>获取焦点时：<br /><a href="http://www.artcss.com/wp-content/uploads/2010/06/textarea.png"><img src="http://www.artcss.com/wp-content/uploads/2010/06/textarea.png" alt="" title="textarea" width="449" height="117" class="alignnone size-full wp-image-833" /></a></p>
<h5>字数限制的javascript代码如下:<span id="more-831"></span></h5>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left2">Download <a href="http://www.artcss.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=831&amp;download=oTab.js">oTab.js</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8312"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p831code2"><pre class="javascript" style="font-family:Verdana;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">function</span> maxLimit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> num<span style="color: #339933;">=</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">0</span><span style="color: #339933;">,</span><span style="color: #ff0000;">140</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">val</span><span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">text</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">length</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;/140&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#textlimit&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">keyup</span><span style="color: #009900;">&#40;</span>maxLimit<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #999999;">//调用方法</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h5>点击下面“运行”直接查看效果</h5>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_iBn0jW">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;meta name=&quot;author&quot; content=&quot;Web Layout:LiQiang.Gu;&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;前端思考 web前端 前端制作 artskin www.artcss.com&quot; /&gt;
&lt;meta name=&quot;Keywords&quot; content=&quot;前端思考 web前端 前端制作 artskin www.artcss.com&quot; /&gt;
&lt;title&gt;textarea的字数限制javascript代码&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.artcss.com/js/jq_1.4.js&quot;&gt;&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
&lt;!--
*{margin:0;padding:0;font-family:Microsoft YaHei,calibri,verdan;}
body{padding:10px;}
.layout{float:left;}
b{display:block;border-color:#fff #fff #ebf3f7;border-style:solid;border-width:8px;font-size:0;height:0;line-height:0;width:0;margin-left:10px;}
.box{background:#ebf3f7;padding:6px;}
.input-button{background:#005EAC;border-color:#B8D4E8 #124680 #124680 #B8D4E8;border-style:solid;border-width:1px;color:#fff;cursor:pointer;
font-size:12px;width:60px;padding:2px 15px;text-align:center;line-height:16px;}
textarea{width:418px;height:22px;border:1px solid #bdc7d8;background:#fff;line-height:20px;padding:0 2px;font-size:14px;word-wrap:break-word;}
.focus{border:1px solid #5D74A2;height:38px;overflow:hidden;overflow-y:auto;}
p{display:none;padding-top:3px;}
p input{float:left;}
p span{color:#ccc;font-size:12px;line-height:25px;padding-left:5px;}
--&gt;
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
	function maxLimit(){
		var num=$(this).val().substr(0,140);
		$(this).val(num);
		$(this).next().children(&quot;span&quot;).text($(this).val().length+&quot;/140&quot;);
	};
	$(&quot;#textlimit&quot;).keyup(maxLimit);
	$(&quot;#textlimit&quot;).focus(function(){
		$(this).addClass(&quot;focus&quot;).next().show();
		if($(this).val() == $(this).attr(&quot;title&quot;)){
			$(this).val(&quot;&quot;);
		}
	});
	$(&quot;#textlimit&quot;).blur(function(){
		if($(this).val().length &gt; 0){
			$(this).addClass(&quot;focus&quot;).next().show();
		}else{
			$(this).removeClass(&quot;focus&quot;).next().hide();
		}
		if($(this).val() == &quot;&quot;){
			$(this).val($(this).attr(&quot;title&quot;));
		}
	});
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;layout&quot;&gt;
	&lt;b&gt;&lt;/b&gt;
	&lt;div class=&quot;box&quot;&gt;
		&lt;textarea name=&quot;textarea&quot; id=&quot;textlimit&quot; cols=&quot;45&quot; rows=&quot;1&quot; title=&quot;添加回复&quot;&gt;添加回复&lt;/textarea&gt;
		&lt;p&gt;
			&lt;input class=&quot;input-button&quot; type=&quot;button&quot; value=&quot;回复&quot; /&gt;
			&lt;span class=&quot;textCount&quot;&gt;0/140&lt;/span&gt;
		&lt;/p&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_iBn0jW');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_iBn0jW');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>经jQuery中文群的一位同仁指点，现把限制字数的子数值用一个参数传进来，以便函数重复利用</</p>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/831.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery滑动导航菜单</title>
		<link>http://www.artcss.com/archives/821.html</link>
		<comments>http://www.artcss.com/archives/821.html#comments</comments>
		<pubDate>Fri, 04 Jun 2010 11:29:21 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[个人随笔]]></category>

		<guid isPermaLink="false">http://www.artcss.com/?p=821</guid>
		<description><![CDATA[今天用jQuery写了个滑动导航菜单，加入了缓动展开的效果。比以前常用的用css伪类:hover+ie6模拟:hover的js写的那个效果好，所以拿出来分享一下，可能还可以更好的改进，欢迎大家多拍砖。 先看一下效果图 实例：Demo 用到的javascript代码如下: Download oTab.js1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 $&#40;function&#40;&#41;&#123; $&#40;&#34;ul.sub&#34;&#41;.parent&#40;&#41;.append&#40;&#34;&#60;span&#62;&#60;/span&#62;&#34;&#41;; $&#40;&#34;ul.sub ul&#34;&#41;.parent&#40;&#41;.append&#40;&#34;&#60;em&#62;&#60;/em&#62;&#34;&#41;; $&#40;'#nav ul'&#41;.closest&#40;'li'&#41;.hover&#40;function&#40;&#41;&#123; $&#40;this&#41;.find&#40;&#34;span&#34;&#41;.addClass&#40;&#34;arrow&#34;&#41;; $&#40;this&#41;.find&#40;&#34;em&#34;&#41;.removeClass&#40;&#34;arrow&#34;&#41;; $&#40;this&#41;.children&#40;&#34;ul&#34;&#41;.stop&#40;true,true&#41;.slideDown&#40;'fast'&#41;.show&#40;&#41;; $&#40;&#34;#nav ul&#62;li&#34;&#41;.hover&#40;function&#40;&#41;&#123;$&#40;this&#41;.addClass&#40;&#34;hover&#34;&#41;&#125;, function&#40;&#41;&#123;$&#40;this&#41;.removeClass&#40;&#34;hover&#34;&#41;&#125;&#41;; &#125;,function&#40;&#41;&#123; $&#40;this&#41;.children&#40;&#34;ul&#34;&#41;.stop&#40;true,true&#41;.hide&#40;&#41;; $&#40;this&#41;.find&#40;&#34;span&#34;&#41;.removeClass&#40;&#34;arrow&#34;&#41;; $&#40;this&#41;.find&#40;&#34;em&#34;&#41;.addClass&#40;&#34;arrow&#34;&#41;; &#125;&#41; &#125;&#41;; 点击下面“运行”直接查看效果 &#60;!DOCTYPE HTML PUBLIC &#34;-//W3C//DTD HTML 4.01//EN&#34; &#34;http://www.w3.org/TR/html4/strict.dtd&#34;&#62; &#60;html&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=utf-8&#34;&#62; &#60;meta name=&#34;author&#34; content=&#34;Web [...]]]></description>
			<content:encoded><![CDATA[<p>今天用jQuery写了个滑动导航菜单，加入了缓动展开的效果。比以前常用的用css伪类:hover+ie6模拟:hover的js写的那个效果好，所以拿出来分享一下，可能还可以更好的改进，欢迎大家多拍砖。</p>
<p>先看一下效果图</p>
<p><a href="http://www.artcss.com/wp-content/uploads/2010/06/menu.jpg"><img src="http://www.artcss.com/wp-content/uploads/2010/06/menu.jpg" alt="" title="menu" width="630" height="200" class="alignnone size-full wp-image-822" /></a></p>
<p>实例：<a href="http://www.artcss.com/test/menu/" target="_blank">Demo</a></p>
<h5>用到的javascript代码如下:<span id="more-821"></span></h5>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left2">Download <a href="http://www.artcss.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=821&amp;download=oTab.js">oTab.js</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8214"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p821code4"><pre class="javascript" style="font-family:Verdana;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.sub&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;span&gt;&lt;/span&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul.sub ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;em&gt;&lt;/em&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#nav ul'</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">closest</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;arrow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;em&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;arrow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fast'</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#nav ul&gt;li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hover&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hover&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;arrow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;em&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;arrow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h5>点击下面“运行”直接查看效果</h5>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_Nxk7gh">
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;meta name=&quot;author&quot; content=&quot;Web Layout:LiQiang.Gu;&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;前端思考 web前端 前端制作 artskin www.artcss.com&quot; /&gt;
&lt;meta name=&quot;Keywords&quot; content=&quot;前端思考 web前端 前端制作 artskin www.artcss.com&quot; /&gt;
&lt;title&gt;下拉导航菜单&lt;/title&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.artcss.com/js/jq_1.4.js&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;stylesheet&quot; rev=&quot;stylesheet&quot; href=&quot;http://www.artcss.com/test/menu/menu.css&quot; type=&quot;text/css&quot; /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
	$(&quot;ul.sub&quot;).parent().append(&quot;&lt;span&gt;&lt;/span&gt;&quot;);
	$(&quot;ul.sub ul&quot;).parent().append(&quot;&lt;em&gt;&lt;/em&gt;&quot;);
	$('#nav ul').closest('li').hover(function(){
		$(this).find(&quot;span&quot;).addClass(&quot;arrow&quot;);
		$(this).find(&quot;em&quot;).removeClass(&quot;arrow&quot;);
		$(this).children(&quot;ul&quot;).stop(true,true).slideDown('fast').show();
		$(&quot;#nav ul&gt;li&quot;).hover(function(){$(this).addClass(&quot;hover&quot;)},function(){$(this).removeClass(&quot;hover&quot;)});
	},function(){
		$(this).children(&quot;ul&quot;).stop(true,true).hide();
		$(this).find(&quot;span&quot;).removeClass(&quot;arrow&quot;);
		$(this).find(&quot;em&quot;).addClass(&quot;arrow&quot;);
	})
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;nav&quot;&gt;
	&lt;ul id=&quot;nav&quot;&gt;
		&lt;li class=&quot;first&quot;&gt;游戏介绍
			&lt;ul class=&quot;sub&quot;&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;first&quot;&gt;新手引导
			&lt;ul class=&quot;sub&quot;&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;
					&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;
					&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;first&quot;&gt;进阶资料
			&lt;ul class=&quot;sub&quot;&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;
					&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;first&quot;&gt;职业技能
			&lt;ul class=&quot;sub&quot;&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;
					&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;
					&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;first&quot;&gt;装备道具
			&lt;ul class=&quot;sub&quot;&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;
					&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;
					&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;
					&lt;ul&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
						&lt;li&gt;&lt;a href=&quot;#&quot;&gt;三级菜单&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;first&quot;&gt;任务指引
			&lt;ul class=&quot;sub&quot;&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;子菜单二&lt;/a&gt;
				&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_Nxk7gh');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_Nxk7gh');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/821.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>网页浮动工具条</title>
		<link>http://www.artcss.com/archives/799.html</link>
		<comments>http://www.artcss.com/archives/799.html#comments</comments>
		<pubDate>Sat, 22 May 2010 13:36:36 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[个人随笔]]></category>
		<category><![CDATA[浮动工具条]]></category>

		<guid isPermaLink="false">http://www.artcss.com/?p=799</guid>
		<description><![CDATA[前两天用jQuery写了个网页浮动工具条，主要效果如下： 1、自动判断浏览器宽度。 当浏览器窗口小于1024时，工具条会自动隐藏 支持浏览器窗口拖拽 2、当拖动浏览器窗口大小时，工具条位置也会相应调整，始终保持贴在网页主体内容右侧。 用到的javascript代码如下: Download showBar.js1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 $&#40;function&#40;&#41;&#123; var name = $&#40;'#float_scroll'&#41;; //浮动工具条的ID function showBar&#40;time&#41;&#123; setTimeout&#40;function&#40;&#41;&#123; $&#40;name&#41;.show&#40;&#41;;&#125;,time&#41;; &#125; [...]]]></description>
			<content:encoded><![CDATA[<p>前两天用jQuery写了个网页浮动工具条，主要效果如下：</p>
<h5>1、自动判断浏览器宽度。</h5>
<p>当浏览器窗口小于1024时，工具条会自动隐藏</p>
<h5>支持浏览器窗口拖拽</h5>
<p>2、当拖动浏览器窗口大小时，工具条位置也会相应调整，始终保持贴在网页主体内容右侧。</p>
<h5>用到的javascript代码如下:</h5>
<p><span id="more-799"></span></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left2">Download <a href="http://www.artcss.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=799&amp;download=showBar.js">showBar.js</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7996"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code" id="p799code6"><pre class="javascript" style="font-family:Verdana;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066;">name</span> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#float_scroll'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #999999;">//浮动工具条的ID</span>
<span style="color: #003366; font-weight: bold;">function</span> showBar<span style="color: #009900;">&#40;</span>time<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	setTimeout<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>time<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> hideBar<span style="color: #009900;">&#40;</span>time<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	setTimeout<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>time<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.oClose'</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
showBar<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #999999;">//hideBar(31000); //页面加载完毕多久后关闭工具条</span>
<span style="color: #003366; font-weight: bold;">var</span> pageW <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.edge&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">offsetWidth</span><span style="color: #339933;">;</span><span style="color: #999999;">//主体页面宽度;</span>
<span style="color: #003366; font-weight: bold;">function</span> scrollBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> offset <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #ff0000;">2</span> <span style="color: #339933;">-</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #ff0000;">2</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">scrollTop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> oLeft<span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #ff0000;">2</span><span style="color: #339933;">+</span>pageW<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		oLeft <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #ff0000;">2</span><span style="color: #339933;">+</span>pageW<span style="color: #339933;">/</span><span style="color: #ff0000;">2</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;=</span> pageW<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		oLeft <span style="color: #339933;">=</span> pageW <span style="color: #339933;">-</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
		oLeft <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>top<span style="color: #339933;">:</span>offset<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>duration<span style="color: #339933;">:</span><span style="color: #ff0000;">200</span><span style="color: #339933;">,</span>queue<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">animate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>left<span style="color: #339933;">:</span>oLeft<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>duration<span style="color: #339933;">:</span><span style="color: #ff0000;">100</span><span style="color: #339933;">,</span>queue<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.num&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">text</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.num2&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">text</span><span style="color: #009900;">&#40;</span>oLeft<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
scrollBar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">resize</span><span style="color: #009900;">&#40;</span>scrollBar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #000066;">scroll</span><span style="color: #009900;">&#40;</span>scrollBar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h5>点击下面“运行”直接查看效果</h5>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_QfVdmw">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;前端思考&quot; /&gt;
&lt;meta name=&quot;keywords&quot; content=&quot;前端思考&quot; /&gt;
&lt;title&gt;网页浮动工具条：前端思考&lt;/title&gt;
&lt;style&gt;
*{margin:0;padding:0px;font-family:Microsoft YaHei,Verdana,Arial;color:#333;}
img{border:none}
h1{padding-bottom:15px;text-align:center}
h2{padding-bottom:20px;}
h3{font-size:16px;}
p{padding:10px;}
ul,li{list-style:none}
.edge{width:880px;padding:10px;height:1500px;background:#fdedd0;border:5px solid #ff9933;margin:0 auto;}
.author{color:#bbb;padding-bottom:30px;padding-right:10px;}
.content{padding:10px 30px;}
.coord{text-align:center;}
.coord span{background:#000099;text-align:center;color:#fff;padding:0 5px;}
/*------浮动工具条-----*/
#float_scroll{position:absolute;width:110px;height:300px;background:url(/test/img/chrome_s.png);z-index:99999;display:none;}
#float_scroll h3{height:26px;padding:3px 0 0 10px;color:#fff;font-size:14px;}
#float_scroll ul{width:48px;margin:0 auto;}
#float_scroll ul li{width:48px;height:48px;padding-top:10px;}
#float_scroll ul li a{display:block;width:48px;height:48px;}
.oClose{display:block;width:44px;height:19px;position:absolute;right:10px;top:0;cursor:pointer;}
.oClose.hover{background:url(/test/img/chrome_s.png) right bottom no-repeat;/*background:#f00;filter:alpha(opacity=50);opacity:0.5;*/}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.artcss.com/js/jq_1.4.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
	$(&quot;.oClose&quot;).hover(function(){$(this).addClass(&quot;hover&quot;);},function(){$(this).removeClass(&quot;hover&quot;);});
	var name = $('#float_scroll'); //浮动工具条的ID
	function showBar(time){
		setTimeout(function(){
			$(name).show();},time);
		}
	function hideBar(time){
		setTimeout(function(){
			$(name).hide();},time);
	}
	$('.oClose').click(function(){
		$(name).hide();
			return false;
	});
	showBar(1000);
	//hideBar(31000); //页面加载完毕多久后关闭工具条
	var pageW = $(&quot;.edge&quot;).get(0).offsetWidth;//主体页面宽度;
	function scrollBar(){
		var offset = $(window).height()/2 - $(name).height()/2 + $(document).scrollTop();
		var oLeft;
		if($(window).width() &gt;= $(name).width()*2+pageW){
			oLeft = $(window).width()/2+pageW/2;
		}else if($(window).width() &lt;= pageW){
			oLeft = pageW - $(name).width();
		}else{
			oLeft = $(window).width() - $(name).width();
		}
		$(name).animate({top:offset},{duration:200,queue:false});
		$(name).animate({left:oLeft},{duration:100,queue:false});
		$(&quot;.num&quot;).text($(window).width());
		$(&quot;.num2&quot;).text(oLeft);
	}
	scrollBar();
	$(window).resize(scrollBar);
	$(window).scroll(scrollBar);
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;edge&quot;&gt;
	&lt;div class=&quot;author&quot;&gt;
		Author: Artcss&lt;br /&gt;
		E-mail:artcss@163.com&lt;br /&gt;
		URL: http://www.artcss.com/?p=799&lt;br /&gt;
	&lt;/div&gt;
	&lt;h1&gt;这里是网页主体内容区域&lt;/h1&gt;
	&lt;div class=&quot;coord&quot;&gt;窗口宽度小于1160时，浮动工具条消失，当前窗口宽度为&lt;span class=&quot;num&quot;&gt;&lt;/span&gt;
	&lt;br /&gt;浮动条的left值为：&lt;span class=&quot;num2&quot;&gt;&lt;/span&gt;&lt;/div&gt;
	&lt;div class=&quot;content&quot;&gt;
		&lt;h2&gt;jQuery浮动工具条&lt;/h2&gt;
		&lt;h3&gt;1、自动判断浏览器宽度。&lt;/h3&gt;
		&lt;p&gt;当浏览器窗口小于1024时，工具条会自动隐藏&lt;/p&gt;
		&lt;h3&gt;支持浏览器窗口拖拽&lt;/h3&gt;
		&lt;p&gt;2、当拖动浏览器窗口大小时，工具条位置也会相应调整，始终保持贴在网页主体内容右侧。&lt;/p&gt;
		&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
		&lt;h2&gt;jQuery浮动工具条&lt;/h2&gt;
		&lt;h3&gt;1、自动判断浏览器宽度。&lt;/h3&gt;
		&lt;p&gt;当浏览器窗口小于1024时，工具条会自动隐藏&lt;/p&gt;
		&lt;h3&gt;支持浏览器窗口拖拽&lt;/h3&gt;
		&lt;p&gt;2、当拖动浏览器窗口大小时，工具条位置也会相应调整，始终保持贴在网页主体内容右侧。&lt;/p&gt;
		&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
		&lt;h2&gt;jQuery浮动工具条&lt;/h2&gt;
		&lt;h3&gt;1、自动判断浏览器宽度。&lt;/h3&gt;
		&lt;p&gt;当浏览器窗口小于1024时，工具条会自动隐藏&lt;/p&gt;
		&lt;h3&gt;支持浏览器窗口拖拽&lt;/h3&gt;
		&lt;p&gt;2、当拖动浏览器窗口大小时，工具条位置也会相应调整，始终保持贴在网页主体内容右侧。&lt;/p&gt;
		&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;float_scroll&quot;&gt;
&lt;h3&gt;工具条&lt;span class=&quot;oClose&quot;&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.artcss.com/&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;/test/img/seo.png&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.artcss.com/&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;/test/img/firebug.png&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.artcss.com/&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;/test/img/ietab.png&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;http://www.artcss.com/&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;/test/img/tools.png&quot; /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_QfVdmw');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_QfVdmw');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/799.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>最简单的代码实现Tab</title>
		<link>http://www.artcss.com/archives/762.html</link>
		<comments>http://www.artcss.com/archives/762.html#comments</comments>
		<pubDate>Tue, 18 May 2010 09:39:24 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[个人随笔]]></category>
		<category><![CDATA[jquery Tab]]></category>
		<category><![CDATA[setInterval]]></category>
		<category><![CDATA[tab切换]]></category>
		<category><![CDATA[自动切换]]></category>

		<guid isPermaLink="false">http://www.artcss.com/?p=762</guid>
		<description><![CDATA[在工作中经常遇到这种Tab切换效果，网上这种效果也是一搜一大堆，但不一定完全适合自己。写过许多次后，发现了一种方法不但代码简洁，而且调用方便，所以分享给大家。 这是基于jquery写的一个Tab，选项卡标题的id和选项卡内容class的名称保持一致即可。 用到的javascript代码如下: Download oTab.js1 2 3 4 5 6 7 8 9 $&#40;function&#40;&#41;&#123; function oTab &#40;&#41;&#123; $&#40;this&#41;.addClass&#40;&#34;current&#34;&#41;.siblings&#40;&#41;.removeClass&#40;&#34;current&#34;&#41;.parent&#40;&#41;.siblings&#40;&#41; .hide&#40;&#41;.siblings&#40;&#34;.&#34;+$&#40;this&#41;.attr&#40;&#34;id&#34;&#41;&#41;.show&#40;&#41;; &#125; //调用方法 $&#40;&#34;.tabt span,.tabt2 span&#34;&#41;.mouseover&#40;oTab&#41;;//同时调用两个或以上 $&#40;&#34;.tabt3 span&#34;&#41;.click&#40;oTab&#41;; &#125;&#41;; 点击下面“运行”直接查看效果 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=gb2312&#34; /&#62; &#60;meta name=&#34;description&#34; content=&#34;前端思考，专注前端开发，关注用户体验，artskin artcss &#34; /&#62; &#60;meta name=&#34;keywords&#34; content=&#34;前端思考,artskin,artcss &#34; /&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>在工作中经常遇到这种Tab切换效果，网上这种效果也是一搜一大堆，但不一定完全适合自己。写过许多次后，发现了一种方法不但代码简洁，而且调用方便，所以分享给大家。</p>
<p>这是基于jquery写的一个Tab，选项卡标题的id和选项卡内容class的名称保持一致即可。</p>
<h5>用到的javascript代码如下:</h5>
<p><span id="more-762"></span></p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left2">Download <a href="http://www.artcss.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=762&amp;download=oTab.js">oTab.js</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7629"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code" id="p762code9"><pre class="javascript" style="font-family:Verdana;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">function</span> oTab <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;current&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;current&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	.<span style="color: #990000;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #999999;">//调用方法</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.tabt span,.tabt2 span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">mouseover</span><span style="color: #009900;">&#40;</span>oTab<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #999999;">//同时调用两个或以上</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.tabt3 span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">click</span><span style="color: #009900;">&#40;</span>oTab<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h5>点击下面“运行”直接查看效果</h5>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_Ojd7ps">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;前端思考，专注前端开发，关注用户体验，artskin artcss &quot; /&gt;
&lt;meta name=&quot;keywords&quot; content=&quot;前端思考,artskin,artcss &quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.artcss.com/js/jq_1.4.js&quot;&gt;&lt;/script&gt;
&lt;title&gt;最简单的弹出层：前端思考&lt;/title&gt;
&lt;style&gt;
*{margin:0;padding:0px;font-family:Microsoft YaHei,Verdana,Arial;}
h2{clear:both;padding:10px;font-size:16px;font-weight:normal}
.tab{margin-left:10px;float:left;display:inline;}
.tab dt{height:20px;}
.tab dt span{display:block;width:50px;height:20px;line-height:20px;text-align:center;float:left;margin-right:1px;display:inline;cursor:default;background:#ddd;}
.tab dt span.current{background:green;color:#fff;}
.tab dd{width:201px;height:100px;font-size:36px;text-align:center;line-height:100px;border:1px solid green;display:none}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
var i=0;
function oTab (){
	$(this).addClass(&quot;current&quot;).siblings().removeClass(&quot;current&quot;).parent().siblings().hide().siblings(&quot;.&quot;+$(this).attr(&quot;id&quot;)).show();
}
$(&quot;.tabt span,.tabt2 span&quot;).mouseover(oTab);
$(&quot;.tabt3 span&quot;).click(oTab);
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h2&gt;一、鼠标滑过（调用两个）&lt;/h2&gt;
&lt;dl class=&quot;tab&quot;&gt;
	&lt;dt class=&quot;tabt&quot;&gt;
		&lt;span id=&quot;t1&quot; class=&quot;current&quot;&gt;111&lt;/span&gt;
		&lt;span id=&quot;t2&quot;&gt;222&lt;/span&gt;
		&lt;span id=&quot;t3&quot;&gt;333&lt;/span&gt;
		&lt;span id=&quot;t4&quot;&gt;444&lt;/span&gt;
	&lt;/dt&gt;
	&lt;dd class=&quot;t1&quot; style=&quot;display:block&quot;&gt;一&lt;/dd&gt;
	&lt;dd class=&quot;t2&quot;&gt;二&lt;/dd&gt;
	&lt;dd class=&quot;t3&quot;&gt;三&lt;/dd&gt;
	&lt;dd class=&quot;t4&quot;&gt;四&lt;/dd&gt;
&lt;/dl&gt;
&lt;dl class=&quot;tab&quot;&gt;
	&lt;dt class=&quot;tabt2&quot;&gt;
		&lt;span id=&quot;c1&quot; class=&quot;current&quot;&gt;111&lt;/span&gt;
		&lt;span id=&quot;c2&quot;&gt;222&lt;/span&gt;
		&lt;span id=&quot;c3&quot;&gt;333&lt;/span&gt;
		&lt;span id=&quot;c4&quot;&gt;444&lt;/span&gt;
	&lt;/dt&gt;
	&lt;dd class=&quot;c1&quot; style=&quot;display:block&quot;&gt;一&lt;/dd&gt;
	&lt;dd class=&quot;c2&quot;&gt;二&lt;/dd&gt;
	&lt;dd class=&quot;c3&quot;&gt;三&lt;/dd&gt;
	&lt;dd class=&quot;c4&quot;&gt;四&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2&gt;二、鼠标点击&lt;/h2&gt;
&lt;dl class=&quot;tab&quot;&gt;
	&lt;dt class=&quot;tabt3&quot;&gt;
		&lt;span id=&quot;d1&quot; class=&quot;current&quot;&gt;111&lt;/span&gt;
		&lt;span id=&quot;d2&quot;&gt;222&lt;/span&gt;
		&lt;span id=&quot;d3&quot;&gt;333&lt;/span&gt;
		&lt;span id=&quot;d4&quot;&gt;444&lt;/span&gt;
	&lt;/dt&gt;
	&lt;dd class=&quot;d1&quot; style=&quot;display:block&quot;&gt;一&lt;/dd&gt;
	&lt;dd class=&quot;d2&quot;&gt;二&lt;/dd&gt;
	&lt;dd class=&quot;d3&quot;&gt;三&lt;/dd&gt;
	&lt;dd class=&quot;d4&quot;&gt;四&lt;/dd&gt;
&lt;/dl&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_Ojd7ps');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_Ojd7ps');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
<p>下面是添加了定时器，tab自动切换的效果</p>
<h5>用到的javascript代码如下:</h5>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left2">Download <a href="http://www.artcss.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=762&amp;download=oTab.js">oTab.js</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p76210"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code" id="p762code10"><pre class="javascript" style="font-family:Verdana;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #ff0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> oTab <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;current&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;current&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	.<span style="color: #990000;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	i <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.tabt4 span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">index</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #999999;">//切换函数</span>
<span style="color: #003366; font-weight: bold;">function</span> oStart<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.tabt4 span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">eq</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;current&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;current&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#auto dd&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">eq</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;dd&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #999999;">//自动切换</span>
<span style="color: #003366; font-weight: bold;">function</span> oTimer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	oStart<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	i<span style="color: #339933;">++;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">==</span><span style="color: #ff0000;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		i<span style="color: #339933;">=</span><span style="color: #ff0000;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #999999;">//设置定时器</span>
<span style="color: #003366; font-weight: bold;">var</span> myTimer <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</span>oTimer<span style="color: #339933;">,</span><span style="color: #ff0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #999999;">//鼠标悬停和移开的情况用hover</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#auto&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>myTimer<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		clearInterval<span style="color: #009900;">&#40;</span>myTimer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	myTimer <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</span>oTimer<span style="color: #339933;">,</span><span style="color: #ff0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #999999;">//调用方法</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.tabt span,.tabt2 span,.tabt4 span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">mouseover</span><span style="color: #009900;">&#40;</span>oTab<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.tabt3 span&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">click</span><span style="color: #009900;">&#40;</span>oTab<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h5>点击下面“运行”直接查看效果</h5>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_pLPQyq">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;前端思考，专注前端开发，关注用户体验，artskin artcss &quot; /&gt;
&lt;meta name=&quot;keywords&quot; content=&quot;前端思考,artskin,artcss &quot; /&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.artcss.com/js/jq_1.4.js&quot;&gt;&lt;/script&gt;
&lt;title&gt;最简单的弹出层：前端思考&lt;/title&gt;
&lt;style&gt;
*{margin:0;padding:0px;font-family:Microsoft YaHei,Verdana,Arial;}
h2{clear:both;padding:10px;font-size:16px;font-weight:normal}
.tab{margin-left:10px;float:left;display:inline;}
.tab dt{height:20px;}
.tab dt span{display:block;width:50px;height:20px;line-height:20px;text-align:center;float:left;margin-right:1px;display:inline;cursor:default;background:#ddd;}
.tab dt span.current{background:green;color:#fff;}
.tab dd{width:201px;height:100px;font-size:36px;text-align:center;line-height:100px;border:1px solid green;display:none}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
var i=0;
function oTab (){
	$(this).addClass(&quot;current&quot;).siblings().removeClass(&quot;current&quot;).parent().siblings().hide()
	.siblings(&quot;.&quot;+$(this).attr(&quot;id&quot;)).show();
	i = $(&quot;.tabt4 span&quot;).index(this);
}
function oStart(i){
	$(&quot;.tabt4 span&quot;).eq(i).addClass(&quot;current&quot;).siblings().removeClass(&quot;current&quot;);
	$(&quot;#auto dd&quot;).eq(i).show().siblings(&quot;dd&quot;).hide();
}
function oTimer(){
	oStart(i);
	i++;
	if(i==4) {
		i=0;
	}
}
var myTimer = setInterval(oTimer,1000);
//鼠标悬停和移开的情况用hover
$(&quot;#auto&quot;).hover(function(){
	if(myTimer) {
		clearInterval(myTimer);
	}
},function(){
	myTimer = setInterval(oTimer,1000);
});
$(&quot;.tabt span,.tabt2 span,.tabt4 span&quot;).mouseover(oTab);
$(&quot;.tabt3 span&quot;).click(oTab);
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h2&gt;一、鼠标滑过（调用两个）&lt;/h2&gt;
&lt;dl class=&quot;tab&quot;&gt;
	&lt;dt class=&quot;tabt&quot;&gt;
		&lt;span id=&quot;t1&quot; class=&quot;current&quot;&gt;111&lt;/span&gt;
		&lt;span id=&quot;t2&quot;&gt;222&lt;/span&gt;
		&lt;span id=&quot;t3&quot;&gt;333&lt;/span&gt;
		&lt;span id=&quot;t4&quot;&gt;444&lt;/span&gt;
	&lt;/dt&gt;
	&lt;dd class=&quot;t1&quot; style=&quot;display:block&quot;&gt;一&lt;/dd&gt;
	&lt;dd class=&quot;t2&quot;&gt;二&lt;/dd&gt;
	&lt;dd class=&quot;t3&quot;&gt;三&lt;/dd&gt;
	&lt;dd class=&quot;t4&quot;&gt;四&lt;/dd&gt;
&lt;/dl&gt;
&lt;dl class=&quot;tab&quot;&gt;
	&lt;dt class=&quot;tabt2&quot;&gt;
		&lt;span id=&quot;c1&quot; class=&quot;current&quot;&gt;111&lt;/span&gt;
		&lt;span id=&quot;c2&quot;&gt;222&lt;/span&gt;
		&lt;span id=&quot;c3&quot;&gt;333&lt;/span&gt;
		&lt;span id=&quot;c4&quot;&gt;444&lt;/span&gt;
	&lt;/dt&gt;
	&lt;dd class=&quot;c1&quot; style=&quot;display:block&quot;&gt;一&lt;/dd&gt;
	&lt;dd class=&quot;c2&quot;&gt;二&lt;/dd&gt;
	&lt;dd class=&quot;c3&quot;&gt;三&lt;/dd&gt;
	&lt;dd class=&quot;c4&quot;&gt;四&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2&gt;二、鼠标点击&lt;/h2&gt;
&lt;dl class=&quot;tab&quot;&gt;
	&lt;dt class=&quot;tabt3&quot;&gt;
		&lt;span id=&quot;d1&quot; class=&quot;current&quot;&gt;111&lt;/span&gt;
		&lt;span id=&quot;d2&quot;&gt;222&lt;/span&gt;
		&lt;span id=&quot;d3&quot;&gt;333&lt;/span&gt;
		&lt;span id=&quot;d4&quot;&gt;444&lt;/span&gt;
	&lt;/dt&gt;
	&lt;dd class=&quot;d1&quot; style=&quot;display:block&quot;&gt;一&lt;/dd&gt;
	&lt;dd class=&quot;d2&quot;&gt;二&lt;/dd&gt;
	&lt;dd class=&quot;d3&quot;&gt;三&lt;/dd&gt;
	&lt;dd class=&quot;d4&quot;&gt;四&lt;/dd&gt;
&lt;/dl&gt;
&lt;h2&gt;三、自动切换&lt;/h2&gt;
&lt;dl id=&quot;auto&quot; class=&quot;tab&quot;&gt;
	&lt;dt class=&quot;tabt4&quot;&gt;
		&lt;span id=&quot;e1&quot; class=&quot;current&quot;&gt;111&lt;/span&gt;
		&lt;span id=&quot;e2&quot;&gt;222&lt;/span&gt;
		&lt;span id=&quot;e3&quot;&gt;333&lt;/span&gt;
		&lt;span id=&quot;e4&quot;&gt;444&lt;/span&gt;
	&lt;/dt&gt;
	&lt;dd class=&quot;e1&quot; style=&quot;display:block&quot;&gt;一&lt;/dd&gt;
	&lt;dd class=&quot;e2&quot;&gt;二&lt;/dd&gt;
	&lt;dd class=&quot;e3&quot;&gt;三&lt;/dd&gt;
	&lt;dd class=&quot;e4&quot;&gt;四&lt;/dd&gt;
&lt;/dl&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_pLPQyq');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_pLPQyq');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/762.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>详解：JavaScript数据类型[转]</title>
		<link>http://www.artcss.com/archives/747.html</link>
		<comments>http://www.artcss.com/archives/747.html#comments</comments>
		<pubDate>Tue, 13 Apr 2010 15:07:21 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.artcss.com/?p=747</guid>
		<description><![CDATA[JavaScript 有六种数据类型。主要的类型有 number、string、object 以及 Boolean 类型,其他两种类型为 null 和 undefined。 String 字符串类型:字符串是用单引号或双引号来说明的。（使用单引号来输入包含引号的字符串。）如：“The cow jumped over the moon.” 数值数据类型：JavaScript 支持整数和浮点数。整数可以为正数、0 或者负数；浮点数可以包含小数点、也可以包含一个 “e”（大小写均可，在科学记数法中表示“10的幂”）、或者同时包含这两项。 Boolean 类型：可能的 Boolean 值有 true 和 false。这是两个特殊值，不能用作 1 和 0。 Undefined 数据类型：一个为 undefined 的值就是指在变量被创建后，但未给该变量赋值以前所具有的值。 Null 数据类型：null 值就是没有任何值，什么也不表示。 object类型：除了上面提到的各种常用类型外，对象也是JavaScript中的重要组成部分，这部分将在后面章节详细介绍。 在 JavaScript 中变量用来存放脚本中的值，这样在需要用这个值的地方就可以用变量来代表，一个变量可以是一个数字，文本或其它一些东西。 　　 JavaScript是一种对数据类型变量要求不太严格的语言，所以不必声明每一个变量的类型，变量声明尽管不是必须的，但在使用变量之前先进行声明是一种好的习惯。可以使用 var 语句来进行变量声明。如：var men = true; // men 中存储的值为 Boolean 类型。 变量命名:JavaScript 是一种区分大小写的语言，因此将一个变量命名为 [...]]]></description>
			<content:encoded><![CDATA[<p>JavaScript 有六种数据类型。主要的类型有 number、string、object 以及 Boolean 类型,其他两种类型为 null 和 undefined。</p>
<p>String 字符串类型:字符串是用单引号或双引号来说明的。（使用单引号来输入包含引号的字符串。）如：“The cow jumped over the moon.”</p>
<p>数值数据类型：JavaScript 支持<span id="more-747"></span>整数和浮点数。整数可以为正数、0 或者负数；浮点数可以包含小数点、也可以包含一个 “e”（大小写均可，在科学记数法中表示“10的幂”）、或者同时包含这两项。</p>
<p>Boolean 类型：可能的 Boolean 值有 true 和 false。这是两个特殊值，不能用作 1 和 0。</p>
<p>Undefined 数据类型：一个为 undefined 的值就是指在变量被创建后，但未给该变量赋值以前所具有的值。</p>
<p>Null 数据类型：null 值就是没有任何值，什么也不表示。</p>
<p>object类型：除了上面提到的各种常用类型外，对象也是JavaScript中的重要组成部分，这部分将在后面章节详细介绍。</p>
<p>在 JavaScript 中变量用来存放脚本中的值，这样在需要用这个值的地方就可以用变量来代表，一个变量可以是一个数字，文本或其它一些东西。</p>
<p>　　 JavaScript是一种对数据类型变量要求不太严格的语言，所以不必声明每一个变量的类型，变量声明尽管不是必须的，但在使用变量之前先进行声明是一种好的习惯。可以使用 var 语句来进行变量声明。如：var men = true; // men 中存储的值为 Boolean 类型。 </p>
<p>变量命名:JavaScript 是一种区分大小写的语言，因此将一个变量命名为 computer 和将其命名为 Computer是不一样的。<br />　　另外，变量名称的长度是任意的，但必须遵循以下规则： <br />
　　 1.第一个字符必须是一个字母（大小写均可）、或一个下划线(_)或一个美元符 ($)。 <br />
　　 2.后续的字符可以是字母、数字、下划线或美元符。 <br />
　　 3.变量名称不能是保留字。
</p>
<p>需要注意js里面var，它控制了变量的作用范围。函数内的变量只要带有var，那么函数内用的这个变量就和函数外的无关。</p>
<div class="cnt">
<p>var a；<br />c=new function(){var a=1;alert(typeof(a));};<br />alert(typeof(a));<br />结果为：number，undefined；</p>
<p>var a=1；<br />c=new function(){alert(typeof(a));var a=1;};<br />alert(typeof(a));<br />结果为：undefined，number；</p>
<p>var a；<br />c=new function(){alert(typeof(a));a=1;};<br />alert(typeof(a));<br />结果为：undefined，number；</p>
<p>var a；</p>
<p>c=new function(){var a=1;alert(typeof(a));};可以在c里面用this.a来访问全局变量a</p>
<p>============</p>
<p>说出它们的值</p>
<p>1、typeof(NaN) number、typeof(Infinity) number、typeof(null) object、typeof(undefined) undefined<br />2、NaN == NaN false<br />3、NaN != NaN true<br />4、NaN &gt;= NaN false<br />5、null == undefined true<br />6、null &gt;= undefined false<br />7、null &lt;= undefined false<br />8、parseInt(&#8220;123abc&#8221;) 123<br />9、&#8221;123abc&#8221; &#8211; 0 NaN<br />10、Infinity &gt; 10 true<br />11、Infinity &gt; &#8220;abc&#8221; false<br />12、Infinity == NaN false<br />13、true == 1 ture<br />14、new String(&#8220;abc&#8221;) == &#8220;abc&#8221; true<br />15、new String(&#8220;abc&#8221;) === &#8220;abc&#8221; false 完全相同</p>
<p><strong>关系运算符</strong><span>（&lt;、&gt;、&lt;=、&gt;=）</span></p>
<ul type="disc">
<li>试图将 expression1 和 expression2 都转换为数字。</li>
<li>如果两表达式均为字符串，则按字典序进行字符串比较。</li>
<li>如果其中一个表达式为 <strong>NaN</strong>，返回 <strong>false</strong>。</li>
<li>负零等于正零。</li>
<li>负无穷小于包括其本身在内的任何数。 </li>
<li>正无穷大于包括其本身在内的任何数。</li>
</ul>
<p><strong>相等运算符</strong><span> （==、!=）</span></p>
<ul type="disc">
<li>如果两表达式的类型不同，则试图将它们转换为字符串、数字或 Boolean 量。 </li>
<li>
<strong>NaN</strong>与包括其本身在内的任何值都不相等。
</li>
<li>负零等于正零。</li>
<li>null 与 null 和 undefined 相等。 </li>
<li>相同的字符串、数值上相等的数字、相同的对象、相同的 Boolean 值或者（当类型不同时）能被强制转化为上述情况之一，均被认为是相等的。</li>
<li>其他比较均被认为是不相等的。</li>
</ul>
<p><strong>恒等运算符</strong><span> （===、!==）</span></p>
<p>除了不进行类型转换，并且类型必须相同以外，这些运算符与相等运算符的作用是一样的。</p>
<p>说出它们的输出结果</p>
<p>1、<br />var a = &#8220;123abc&#8221;;<br />alert(typeof(a++)); string，++运算符在typeof时候没有执行<br />alert(a); NaN</p>
<p>2、a是string类型<br />var a = &#8220;123abc&#8221;;<br />a.valueOf = function(){return parseInt(a);}<br />alert(++a); NaN<br />alert(a-0); NaN</p>
<p>3、a是object类型<br />var a = new Object();<br />a.toString = function(){return &#8220;123abc&#8221;;}<br />a.valueOf = function(){return parseInt(a);}<br />alert(++a);124<br />alert(a-0);124</p>
<p>4、<br />String.prototype.valueOf = function(){<br />return parseFloat(this);<br />}<br />alert(&#8220;123abc&#8221; &gt; 122); false<br />alert(new String(&#8220;123abc&#8221;) &gt; 122); true</p>
<p>5、<br />var s = new String(&#8220;abc&#8221;);<br />alert(typeof(s) == typeof(&#8220;abc&#8221;));false<br />alert(s === &#8220;abc&#8221;);false<br />alert(s.toString() == s);true</p>
<p>6、<br />var a = new Object();<br />a.toString = function(){return &#8220;a&#8221;};<br />var b = new Object();<br />b.toString = function(){return &#8220;b&#8221;};<br />alert(a&gt;b);<br />a.valueOf = function(){return 1};<br />b.valueOf = function(){return 0};<br />alert(a&gt;b);</p>
<p>7、<br />function step(a){<br />return function(x)<br />{<br />return x + a++;<br />}<br />}<br />var a = step(10);<br />var b = step(20);<br />alert(a(10));<br />alert(b(10));</p>
</div>
<p>原文地址：<a href="http://www.javaeye.com/topic/427150">http://www.javaeye.com/topic/427150</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/747.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>jQuery1.4官方文档中文版[转]</title>
		<link>http://www.artcss.com/archives/677.html</link>
		<comments>http://www.artcss.com/archives/677.html#comments</comments>
		<pubDate>Mon, 22 Feb 2010 02:47:59 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[chm]]></category>
		<category><![CDATA[中文文档]]></category>

		<guid isPermaLink="false">http://blog.artskin.cn/?p=677</guid>
		<description><![CDATA[2010年1月14号, 恰逢jQuery四周年纪念日, jQuery的团队早早便开始了1.4版发布的准备工作, 并以每天一则公告的方式进行庆祝, 活动将持续14天。发布的首日, jQuery的团队首先列出了1.4版中的重大改进。我个人认为这篇文档是这几天以来内容比较充实的一篇文档。所以翻译过来, 以便同僚日后可以参考。时间仓促, 可能有几处不太明确的地方, 或是原文就草草带过, 可能会不大通畅。欢迎讨论或提出意见，以便共同进步。 原译者:coolnalu 原文地址: http://jquery14.com/day-01 .wp_syntax { color: #100; background-color: #f9f9f9; border: 1px solid silver; margin: 0 0 1.5em 0; overflow: auto; } .wp_syntax div{ vertical-align: top; padding: 2px 4px; } .entry h2{ background: #eeeeee; padding: 5px; } jQuery 1.4 发布啦 为了庆祝jQuery的四周岁生日, jQuery的团队荣幸的发布了jQuery Javascript库的最新主要版本! 这个版本包含了大量的编程，测试，和记录文档的工作，我们为此感到很骄傲。 我要以个人的名义感谢 Brandon [...]]]></description>
			<content:encoded><![CDATA[<p>2010年1月14号, 恰逢jQuery四周年纪念日, jQuery的团队早早便开始了1.4版发布的准备工作, 并以每天一则公告的方式进行庆祝, 活动将持续14天。发布的首日, jQuery的团队首先列出了1.4版中的重大改进。我个人认为这篇文档是这几天以来内容比较充实的一篇文档。所以翻译过来, 以便同僚日后可以参考。时间仓促, 可能有几处不太明确的地方, 或是原文就草草带过, 可能会不大通畅。欢迎讨论或提出意见，以便共同进步。<br />
<strong>原译者:coolnalu</strong></p>
<p><span id="more-69"></span><br />
<a href="http://jquery14.com/day-01">原文地址: http://jquery14.com/day-01</a></p>
<style>
.wp_syntax {
  color: #100;
  background-color: #f9f9f9;
  border: 1px solid silver;
  margin: 0 0 1.5em 0;
  overflow: auto;
}
.wp_syntax div{
  vertical-align: top;
  padding: 2px 4px;
}
.entry h2{
  background: #eeeeee;
  padding: 5px;
}
</style>
<h3>jQuery 1.4 发布啦</h3>
<p>为了庆祝jQuery的四周岁生日, jQuery的团队荣幸的发布了jQuery Javascript库的最新主要版本! 这个版本包含了大量的编程，测试，和记录文档的工作，我们为此感到很骄傲。</p>
<p>我要以个人的名义感谢 Brandon Aaron, Ben Alman, Louis-Rémi Babe, Ariel Flesler, Paul Irish, Robert Kati?, Yehuda Katz, Dave Methvin, Justin Meyer, Karl Swedberg, and Aaron Quint。谢谢他们在修复BUG和完成这次发布上所做的工作。</p>
<h4>下载(Downloading)</h4>
<p>按照惯例，我们提供了两份jQuery的拷贝，一份是最小化的(我们现在采用<a href="http://code.google.com/closure/compiler/">Google Closure</a>作为默认的压缩工具了)，一份是未压缩的(供纠错或阅读)。</p>
<ul>
<li><a href="http://code.jquery.com/jquery-1.4.min.js">jQuery压缩</a> (23kb <a href="http://www.julienlecomte.net/blog/2007/08/13/">Gzipped</a>)</li>
<li><a href="http://code.jquery.com/jquery-1.4.js">jQuery常规</a> (234kb)</li>
<li><a href="http://blog.artskin.cn/?page_id=486">jQuery1.4API中文文档手册chm</a> (154kb)</li>
</ul>
<p>另外，Google也在他们的服务器上<a href="http://code.google.com/apis/ajaxlibs/documentation/index.html">放置了一份jQuery的拷贝</a>。这份拷贝会自动的最小化然后压缩 &ndash; 并且放在Google最快的缓存服务器上。</p>
<ul>
<li><a href="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js">http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js</a></li>
</ul>
<p>你可以在你的站点上直接引用上面的URL，这样就可以享受迅速加载jQuery的性能优势了。</p>
<p>就jQuery1.4来说，我们努力的减少大规模升级中的麻烦 &ndash; 通过保持所有public函数的签名。即使如此，还请通读<a href="#backwards">可能会造成问题的变更列表</a>，这样能够了解哪些变更可能会给你的应用造成问题。</p>
<h3>(功能) Features</h3>
<p>下面的内容概括了jQuery1.4里加入的变更和功能。另外所有的变更都已经在<a href="http://api.jquery.com/category/version/1.4/">jQuery 1.4 的文档</a>里记录了。</p>
<h4>热门方法经过了性能上的大”检修”</h4>
<p>不少比较热门的和常用的jQuery方法在1.4里被重写了。(译注:重写了方法的内部，外部调用没有大幅度改变) 我们分析源码的时候发现我们能够获得大幅的性能提升，通过把jQuery和自己比较: 查看内部函数被调用了多少次，然后努力<a href="http://ejohn.org/blog/function-call-profiling/">降低源码的复杂度</a>(译注:计算机算法中的Complexity)</p>
<p><a rel="lightbox[69]" href="http://www.uxd2.com/wp-content/uploads/2010/01/01-funccall.jpg"><img width="500" height="375" alt="常用jQuery方法调用频率" src="http://www.uxd2.com/wp-content/uploads/2010/01/01-funccall.jpg" title="常用jQuery方法调用频率" class="alignnone size-full wp-image-74"></a><br />
<small><a href="http://www.flickr.com/photos/jeresig/4271691293/" title="# of Function Calls for Popular jQuery Methods by John Resig, on Flickr">View the cropped chart.</a></small></p>
<p>在1.4版里我们显著的降低了大部分热门jQuery方法的的复杂度。</p>
<h4>更易用的设置函数 (Easy Setter Functions)</h4>
<p>算来已经有一阵了，你们已经可以给<code><a href="http://api.jquery.com/attr">.attr()</a></code>传递一个函数，然后这个函数的结果会被用来赋给相应的HTML属性(attribute)上。这个功能现在被移植到所有的设置函数了: <code><a href="http://api.jquery.com/css">.css()</a></code>, <code><a href="http://api.jquery.com/attr">.attr()</a></code>, <code><a href="http://api.jquery.com/val">.val()</a></code>, <code><a href="http://api.jquery.com/html">.html()</a></code>, <code><a href="http://api.jquery.com/text">.text()</a></code>, <code><a href="http://api.jquery.com/append">.append()</a></code>, <code><a href="http://api.jquery.com/prepend">.prepend()</a></code>,  <code><a href="http://api.jquery.com/before">.before()</a></code>, <code><a href="http://api.jquery.com/after">.after()</a></code>, <code><a href="http://api.jquery.com/replaceWith">.replaceWith()</a></code>, <code><a href="http://api.jquery.com/wrap">.wrap()</a></code>, <code><a href="http://api.jquery.com/wrapInner">.wrapInner()</a></code>, <code><a href="http://api.jquery.com/offset">.offset()</a></code>, <code><a href="http://api.jquery.com/addClass">.addClass()</a></code>, <code><a href="http://api.jquery.com/removeClass">.removeClass()</a></code>, 以及 <code><a href="http://api.jquery.com/toggleClass">.toggleClass()</a></code>.</p>
<p>另外, 对于下面几个方法，当前的值会被作为第2个变量传递给这个函数。<code><a href="http://api.jquery.com/css">.css()</a></code>, <code><a href="http://api.jquery.com/attr">.attr()</a></code>, <code><a href="http://api.jquery.com/val">.val()</a></code>, <code><a href="http://api.jquery.com/html">.html()</a></code>, <code><a href="http://api.jquery.com/text">.text()</a></code>, <code><a href="http://api.jquery.com/append">.append()</a></code>, <code><a href="http://api.jquery.com/prepend">.prepend()</a></code>, <code><a href="http://api.jquery.com/offset">.offset()</a></code>, <code><a href="http://api.jquery.com/addClass">.addClass()</a></code>, <code><a href="http://api.jquery.com/removeClass">.removeClass()</a></code>, 以及 <code><a href="http://api.jquery.com/toggleClass">.toggleClass()</a></code>.</p>
<p>这样代码就可以这样写:</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript"><span style="color: rgb(0, 102, 0); font-style: italic;">// 找出所有A标签里的'&amp;'字符，然后用一个span标签包围</span>
$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">'a'</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">html</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span>i<span style="color: rgb(51, 153, 51);">,</span>html<span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 153, 0);">{</span>
  <span style="color: rgb(0, 0, 102); font-weight: bold;">return</span> html.<span style="color: rgb(102, 0, 102);">replace</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 102); font-style: italic;">/&amp;/gi</span><span style="color: rgb(51, 153, 51);">,</span><span style="color: rgb(51, 102, 204);">'<span class="amp">&amp;</span>'</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>

<span style="color: rgb(0, 102, 0); font-style: italic;">// 给一些链接的title属性加些信息</span>
$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">'a[target]'</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">attr</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"title"</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span>i<span style="color: rgb(51, 153, 51);">,</span>title<span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 153, 0);">{</span>
  <span style="color: rgb(0, 0, 102); font-weight: bold;">return</span> title <span style="color: rgb(51, 153, 51);">+</span> <span style="color: rgb(51, 102, 204);">" (新窗口打开)"</span><span style="color: rgb(51, 153, 51);">;</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<h4>Ajax</h4>
<p><strong>嵌套参数的序列化</strong> (<a href="http://api.jquery.com/jQuery.param/">jQuery.param() 文档</a>, <a href="http://github.com/jquery/jquery/commit/50d78e7658382d2a2f5149cae7a6572f78ce403f">Commit 1</a>, <a href="http://github.com/jquery/jquery/commit/67089eedf6f84acd9c16ea2a6dadadf7b13a7c84">Commit 2</a>)</p>
<p>jQuery 1.4在jQuery.param方法里加入了嵌入参数序列化的支持，借用了PHP编程里兴起的，而后又被Ruby on Rails推广开来的方式。<br />
举例来说，<br />
<code>{foo: ["bar", "baz"]}</code> 会被序列化为 “foo[]=bar&amp;foo[]=baz”.</p>
<p>在jQuery 1.3版里, <code>{foo: ["bar", "baz"]}</code> 曾被序列化为 “foo=bar&amp;foo=baz”. 但是，这样做没用办法将只含有一个元素的阵列编码。如果你需要旧的序列化方式，你可以设置传统Ajax设置来进行切换。(使用<code>jQuery.ajaxSettings.traditional</code>进行全局切换，或者根据情况单独切换。</p>
<p>总共有3种方式可以切换到旧的序列化方式:</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript"><span style="color: rgb(0, 102, 0); font-style: italic;">// 全局改变序列化方式 (使用旧的)</span>
jQuery.<span style="color: rgb(102, 0, 102);">ajaxSettings</span>.<span style="color: rgb(102, 0, 102);">traditional</span> <span style="color: rgb(51, 153, 51);">=</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">true</span><span style="color: rgb(51, 153, 51);">;</span>

<span style="color: rgb(0, 102, 0); font-style: italic;">// 指定情况使用旧的序列化方式</span>
jQuery.<span style="color: rgb(102, 0, 102);">param</span><span style="color: rgb(0, 153, 0);">(</span> stuff<span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">true</span> <span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>

<span style="color: rgb(0, 102, 0); font-style: italic;">// 针对一个单独的Ajax请求使用旧的序列化方式</span>
$.<span style="color: rgb(102, 0, 102);">ajax</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">{</span> data<span style="color: rgb(51, 153, 51);">:</span> stuff<span style="color: rgb(51, 153, 51);">,</span> traditional<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">true</span> <span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p>更多信息参见: <a href="http://api.jquery.com/jQuery.param/">jQuery.param() 文档</a>, <a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax() 文档</a>, <a href="http://github.com/jquery/jquery/commit/39518945047413f1185682078043e70e0c5c9091">Commit</a>, <a href="http://github.com/jquery/jquery/blob/master/src/ajax.js#L175">Code</a></p>
<p><strong>JSON和脚本类型通过”content-type”自动识别。</strong> (<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax 文档</a>, <a href="http://github.com/jquery/jquery/commit/787f271052220c20787104f0eba6441aedac22ff">Commit 1</a>, <a href="http://github.com/jquery/jquery/commit/6861b5d4eb16222ed5ea623af6ce75362b55d1d4">Commit 2</a>)</p>
<p>如果一个Ajax请求的回复的媒体类型是JSON(application/json), dataType默认设为”json”(如果dataType没有被指明)。另外，如果回复的媒体类型是Javascript(application/javascript), dataType默认设为”script”(同样，如果dataType没有明确指明), 这种情况下，脚本会自动运行。</p>
<p><strong>加入了Etag的支持</strong> (<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax() 文档</a>, <a href="http://github.com/jquery/jquery/commit/28ab4d32247943e1ae3409b23fe69303df0bc9eb">Commit</a>)</p>
<p>默认设置下, jQuery会忽略Ajax请求的”Last-Modified”页头。这样做是为了忽略浏览器的缓存。设置ifModified:true就可以使jQuery使用可用的缓存。jQuery1.4还会发出”If-None-Match”的页头如果你设置了ifModified选项。</p>
<p><strong>严格JSON模式，本地的JSON.parse方法</strong> (<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax() 文档</a>, <a href="http://github.com/jquery/jquery/commit/90a87c03b4943d75c24bc5e6246630231d12d933">Commit 1</a>, <a href="http://github.com/jquery/jquery/commit/308d6cdad023da190ace2a698ee4815ed8dad9c5">Commit 2</a>, <a href="http://github.com/jquery/jquery/commit/44e6beb10304789044de2c5a58f5bb82e8321636">Commit 3</a>)</p>
<p>jQuery 1.3和以前的版本曾使用Javascript的<code>eval</code>对引入的JSON解析。1.4版则会使用本地的JSON解析器，前提是如果有本地的解析器可用。它也会对引入的JSON进行校验。所以在<a href="http://api.jquery.com/jQuery.getJSON">jQuery.getJSON</a>方法里，或当一个Ajax请求的dataType是”json”的时候，jQuery会拒绝不合标准的JSON(例如<code>{foo: "bar"}</code>)。</p>
<p><strong>序列化HTML5的元素</strong> (<a href="http://api.jquery.com/jQuery.param/">jQuery.param() 文档</a>, <a href="http://github.com/jquery/jquery/commit/b31b9bd756a1489c3b1b856ed8b624c55da9e02f">Commit</a>)</p>
<p>新的<a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#attr-input-type-keywords">HTML5输入方法</a> (比如’datetime’和’range’)在序列化<code><a href="http://api.jquery.com/serialize">.serialize()</a></code>一个表单的时候会被包括在内。</p>
<p><strong>Ajax请求的环境</strong> (<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax() 文档</a>, <a href="http://github.com/jquery/jquery/commit/183f37e4b4128af7ba096ac40046768b84b6d66e">Commit</a>)</p>
<p>你可以附加一个”环境”到Ajax请求上，所有的回调函数里都会拥有同样的”环境”设置(这样可以简化你的代码，尽可能避免使用闭合,或是其他对象)。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">jQuery.<span style="color: rgb(102, 0, 102);">ajax</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">{</span>
    url<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(51, 102, 204);">"test.html"</span><span style="color: rgb(51, 153, 51);">,</span>
    context<span style="color: rgb(51, 153, 51);">:</span> document.<span style="color: rgb(102, 0, 102);">body</span><span style="color: rgb(51, 153, 51);">,</span>
    success<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 153, 0);">{</span>
        jQuery<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 0, 102); font-weight: bold;">this</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">addClass</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"done"</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
    <span style="color: rgb(0, 153, 0);">}</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p><strong>请求成功回调函数的第三个参数会被设为原始的XHR对象</strong> (<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax() 文档</a>, <a href="http://github.com/jquery/jquery/commit/c2101245c07afdb831b0c79869c7263420407b67">Commit</a>)</p>
<p>所有的Ajax请求的成功回调函数现在都会收到原始的XMLHttpRequest对象，作为第三个参数。之前这个XHR对象只能通过<code>$.ajax</code>一类方法的返回值来获取。</p>
<p><strong>明确设置”Content-Type”</strong> (<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax() 文档</a>, <a href="http://github.com/jquery/jquery/commit/25b0ba9f9612583033b902a0e40345463a3a71d0">Commit</a>)</p>
<p>在1.3版，如果没有实际数据发送，<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax</a>的contentType会被忽略。1.4版里，contentType将总是和请求一同发送。这修复了某些后台凭靠”Content-Type”页头判断回复类别所造成的问题。</p>
<p><strong>明确设置JSONP回调函数的名字</strong> (<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax 文档</a>,  <a href="http://github.com/jquery/jquery/commit/fbc73d45b487dd863886c7fd3f0af1fd4dec261b">Commit</a>)</p>
<p>你可以使用<a href="http://api.jquery.com/jQuery.ajax/">jQuery.ajax()</a>方法的jsonpCallback选项，通过名字来指定JSONP的回调函数。</p>
<p><strong>防止启动前跨域XHR</strong> (<a href="http://github.com/jquery/jquery/commit/a7678267d848fcef8775c8b9f4fa3e507b8cc5f4">Commit</a>)</p>
<p>跨域Ajax(针对提供支持的浏览器)将更易用，因为默认设置下，启动前XHR被阻止了。(TODO)</p>
<p><strong>jQuery.ajax()现在使用”onreadystatechange”事件替换了计时器</strong> (<a href="http://github.com/jquery/jquery/commit/fe6c86d53046b0f4d648f61c0b8e75387af65152">Commit</a>)</p>
<p>使用”onreadystatechange”替换了轮流探询，Ajax请求现在将使用更少的资源</p>
<h4>元素属性 (Attributes)</h4>
<p><strong><code>.css()</code>和<code>.attr()</code> 的性能被优化了。</strong></p>
<p>&lt;<a rel="lightbox[69]" href="http://www.uxd2.com/wp-content/uploads/2010/01/02-perform-cssatrr.jpg"><img width="500" height="375" alt=".css().attr()的性能提高" src="http://www.uxd2.com/wp-content/uploads/2010/01/02-perform-cssatrr.jpg" title=".css().attr()的性能提高" class="alignnone size-full wp-image-75"></a></p>
<p><strong><code>.attr()</code>方法多了一个设置函数作为参数</strong> (<a href="http://api.jquery.com/attr/">.attr() 文档</a>)</p>
<p>你不但可以将一个函数用在<code>.attr()</code>里，还可以在这个函数里使用属性的当前值。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">jQuery<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">'&lt;img src="enter.png" alt="enter your name" /&gt;'</span><span style="color: rgb(0, 153, 0);">)</span>
.<span style="color: rgb(102, 0, 102);">attr</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"alt"</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span>index<span style="color: rgb(51, 153, 51);">,</span> value<span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
    <span style="color: rgb(0, 0, 102); font-weight: bold;">return</span> <span style="color: rgb(51, 102, 204);">"Please, "</span> <span style="color: rgb(51, 153, 51);">+</span> value<span style="color: rgb(51, 153, 51);">;</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p><strong>.val( Function )</strong> (<a href="http://api.jquery.com/val/">.val() 文档</a>)</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="html4strict"><span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">input</span> <span style="color: rgb(0, 0, 102);">class</span><span style="color: rgb(102, 204, 102);">=</span><span style="color: rgb(255, 0, 0);">"food"</span> <span style="color: rgb(0, 0, 102);">type</span><span style="color: rgb(102, 204, 102);">=</span><span style="color: rgb(255, 0, 0);">'text'</span> data-index<span style="color: rgb(102, 204, 102);">=</span><span style="color: rgb(255, 0, 0);">"0"</span> <span style="color: rgb(102, 204, 102);">/</span>&gt;</span>
<span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">input</span> <span style="color: rgb(0, 0, 102);">class</span><span style="color: rgb(102, 204, 102);">=</span><span style="color: rgb(255, 0, 0);">"food"</span> <span style="color: rgb(0, 0, 102);">type</span><span style="color: rgb(102, 204, 102);">=</span><span style="color: rgb(255, 0, 0);">'text'</span> data-index<span style="color: rgb(102, 204, 102);">=</span><span style="color: rgb(255, 0, 0);">"1"</span> <span style="color: rgb(102, 204, 102);">/</span>&gt;</span></pre>
</div>
</div>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">jQuery<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"input:text.food"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">hide</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>

jQuery<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"&lt;ul class='sortable'&gt;&lt;li&gt;Peanut Butter&lt;/li&gt;&lt;li&gt;Jelly&lt;/li&gt;&lt;/ul&gt;"

</span><span style="color: rgb(0, 153, 0);">)</span>
  .<span style="color: rgb(102, 0, 102);">sortable</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span>
  .<span style="color: rgb(102, 0, 102);">bind</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"endsort"</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
    $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">":text.food"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">val</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
      <span style="color: rgb(0, 0, 102); font-weight: bold;">return</span> $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"ul.sortable li:eq("</span> <span style="color: rgb(51, 153, 51);">+</span> $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 0, 102); font-weight: bold;">this</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">attr</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"data-index"</span><span style="color: rgb(0, 153, 0);">)</span>  <span style="color: rgb(51, 153, 51);">+</span> <span style="color: rgb(51, 102, 204);">")"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">text</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
    <span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
  <span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p><strong>text和CDATAHTML元素也支持.text()方法了</strong> (<a href="http://api.jquery.com/text/">.text() 文档</a>, <a href="http://github.com/jquery/jquery/commit/b30af34f28074b491929445f5aad3d62c63e772f">Commit</a>)</p>
<h4>核心 (Core)</h4>
<p><strong>快捷元素创建</strong> (<a href="http://api.jquery.com/jQuery/#jQuery2">jQuery() 文档</a>, <a href="http://github.com/jquery/jquery/commit/d40083c866738727aa7ffd7f13d2955bc9575d5e">Commit</a>)</p>
<p>现在当你需要使用jQuery函数创建一个元素的时候，你可以同时附递一个对象来指定属性值和事件:</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">jQuery<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"
<div>"<span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(0, 153, 0);">{</span>
    id<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(51, 102, 204);">"foo"</span><span style="color: rgb(51, 153, 51);">,</span>
    css<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(0, 153, 0);">{</span>
        height<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(51, 102, 204);">"50px"</span><span style="color: rgb(51, 153, 51);">,</span>
        width<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(51, 102, 204);">"50px"</span><span style="color: rgb(51, 153, 51);">,</span>
        color<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(51, 102, 204);">"blue"</span><span style="color: rgb(51, 153, 51);">,</span>
        backgroundColor<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(51, 102, 204);">"#ccc"</span>
    <span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(51, 153, 51);">,</span>
    click<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
       $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 0, 102); font-weight: bold;">this</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">css</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"backgroundColor"</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(51, 102, 204);">"red"</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
    <span style="color: rgb(0, 153, 0);">}</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">appendTo</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"body"</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></div>

</span></pre>
</div>
</div>
<p>对象里的键值的名字与相关的jQuery的方法的名字是对应的，对象的值会被作为参数传递给jQuery的方法。</p>
<p>(译注:譬如<code>$("&lt;a&gt;link&lt;/a&gt;", {css:{background:"#ccc"}});</code>相当于<code>$("&lt;a&gt;link&lt;/a&gt;")).css("background", "#ccc");</code></p>
<p><strong>.eq(-N), .get(-N) (负指数)</strong> (<a href="http://api.jquery.com/eq/">.eq() 文档</a>, <a href="http://api.jquery.com/get/">.get() 文档</a>, <a href="http://github.com/jquery/jquery/commit/e532dfe5228217f55a33122a4438fd70522dbb4b">Commit</a>)</p>
<p>你现在可以在<code>.get()</code>和<code>.eq()</code>方法里使用负数。譬如，你要选择倒数第2个div元素，或者是倒数第2个DOM对象:</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"div"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">eq</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 153, 51);">-</span><span style="color: rgb(204, 0, 0);">2</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"div"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">get</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 153, 51);">-</span><span style="color: rgb(204, 0, 0);">2</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p><strong>新的.first()和.last()方法</strong> (<a href="http://api.jquery.com/first/">.first() 文档</a>, <a href="http://api.jquery.com/last/">.last() 文档</a>, <a href="http://github.com/jquery/jquery/commit/9de120e6d7cfffa3d990a6ccf23db3cd74e2bdc0">Commit</a>)</p>
<p>方便起见, 新增的<code>.first()</code>和<code>.last()</code>方法等同于<a href="http://api.jquery.com/eq/">.eq(0)</a>和<a href="http://api.jquery.com/eq/">.eq(-1)</a>.</p>
<p><strong>新的.toArray()方法</strong> (<a href="http://api.jquery.com/toArray/">.toArray() 文档</a>, <a href="http://github.com/jquery/jquery/commit/e124fec5e9cfee77cb23b27c0d43dc2631c83aab">Commit</a>)</p>
<p><a href="http://api.jquery.com/get">.get()</a>方法自始就是从jQuery集合里返回一个阵列。为了能够更明确, 你可以用<a href="http://api.jquery.com/toArray/">.toArray()</a>来达到一样的效果。(译注:这里应该是为了以后的版本留出空间，譬如以后可能会加入.toList()方法，到时候就会易于区分。) 不过，和<code>.get()</code>不一样的是，<code>.toArray()</code>不接受参数。</p>
<p><strong>jQuery()返回一个空集</strong> (<a href="http://api.jquery.com/jQuery/">jQuery() 文档</a>, <a href="http://github.com/jquery/jquery/commit/04524287d3e0112deae570ff9247c734833431bb">Commit</a>)</p>
<p>在jQuery 1.3中,<a href="http://api.jquery.com/jQuery/">jQuery()</a>方法返回仅包括<code>document</code>的jQuery集合。这个可以用来创建一个空集，然后动态加入一些元素。注: <code>jQuery().ready()</code>方式在1.4中依然有效，但是被指示陈旧了。请使用<code>jQuery(document).ready()</code>或者<code>jQuery(function(){})</code>。</p>
<p><strong>jQuery(“TAG”)</strong> (<a href="http://api.jquery.com/element-selector/">Element Selector 文档</a>, <a href="http://github.com/jquery/jquery/commit/4ea4fad0902839c06c281b5de7b0aca29922b63d">Commit</a>)</p>
<p>当使用单个标签名字的时候jQuery会使用更快捷的路径。</p>
<p><strong>jQuery(“&lt;div&gt;”), jQuery(“&lt;div/&gt;”) 和 jQuery(“&lt;div&gt;&lt;/div&gt;”)</strong> (<a href="http://api.jquery.com/jQuery/#jQuery2">jQuery() 文档</a>, <a href="http://github.com/jquery/jquery/commit/c4c820efff4fa7bcce0d5bf0a448625278ea6379">Commit</a>)</p>
<p>现在这三个方法都使用同一个代码路径了(document.createElement), 来优化<code>jQuery("&lt;div&gt;&lt;/div&gt;")</code>的性能。注意，如果你指定了属性，将会使用浏览器本身的语法分析(通过设置innerHTML)。</p>
<h4>样式 (CSS)</h4>
<p><strong>.css()方法在性能是以前的2倍。</strong></p>
<p><a rel="lightbox[69]" href="http://www.uxd2.com/wp-content/uploads/2010/01/03-perform-css.jpg"><img width="500" height="375" alt=".css()的性能提高 " src="http://www.uxd2.com/wp-content/uploads/2010/01/03-perform-css.jpg" title=".css()的性能提高 " class="alignnone size-full wp-image-76"></a></p>
<p><strong><code>.addClass()</code>, <code>.removeClass()</code>, 和 <code>.hasClass()</code>这几个方法在性能上是以前的3倍</strong></p>
<p><a rel="lightbox[69]" href="http://www.uxd2.com/wp-content/uploads/2010/01/04-perform-addClass.jpg"><img width="500" height="375" alt="addClass, removeClass, 和 hasClass的性能提高" src="http://www.uxd2.com/wp-content/uploads/2010/01/04-perform-addClass.jpg" title="addClass, removeClass, 和 hasClass的性能提高" class="alignnone size-full wp-image-77"></a></p>
<p><strong>.toggleClass()可以切换多个css类了</strong> (<a href="http://api.jquery.com/toggleClass/">.toggleClass() 文档</a>, <a href="http://github.com/jquery/jquery/commit/5e6e53835e552920db4f88ac0c9eca71aaacbef0">Commit</a>)</p>
<p>你可以通过<a href="http://api.jquery.com/toggleClass/">.toggleClass()</a>调用多个css类的名字来切换他们。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"div"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">toggleClass</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"current active"</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<h4>数据</h4>
<p><strong>.data()返回对象, .data(Object)设置对象</strong> (<a href="http://api.jquery.com/data/">.data() 文档</a>, <a href="http://github.com/jquery/jquery/commit/d36d224cc52e70d837306d33a03f517ef72abc60">Commit 1</a>, <a href="http://github.com/jquery/jquery/commit/f6a0bf6816f4e2e67382b1b13fdd3ff2ea4b22f8">Commit 2</a>)</p>
<p>有时候你可能需要在一个元素上附加一个复杂的对象。一个常见的例子是你需要从一个元素身上复制所有的数据到令一个元素上。在jQuery 1.4里, 不使用任何参数调用<a href="http://api.jquery.com/data/">.data()</a>时，.data会返回一个复杂对象。(译注: 包含所有键-值对的对象。) 调用<a href="http://api.jquery.com/data/">.data(Object)</a> 则会设置这个对象。注意这个对象还包括了元素上绑定的事件，所以用的时候要小心。</p>
<p><strong>除非需要, 不然不会创建数据缓存。</strong> (<a href="http://github.com/jquery/jquery/commit/c4f144eeffd94c745839b0ced2de9c62cfa9f075">Commit 1</a>, <a href="http://github.com/jquery/jquery/commit/97e134fe80a734b97170bf43c9459511f4e165c7">Commit 2</a>, <a href="http://github.com/jquery/jquery/commit/67d445a703491c90a7d3c46be34bcdceb4d1c896">Commit 3</a>)</p>
<p>jQuery使用一个独特的自定义属性来获取特定元素上附加的数据。当查找数据，但是没有新加的数据的时候，jQuery会尽量避免创建这个自定义属性。这样可能会提高性能，同时还会在这种情况下避免污染DOM。</p>
<h4>效果 (Effects)</h4>
<p><strong>单个属性缓进缓出</strong> (<a href="http://api.jquery.com/animate/#per-property-easing">Per-property Easing 文档</a>, <a href="http://github.com/jquery/jquery/commit/93fdbeb963a9c350f807818c7cc99982942a92f3">Commit</a>)</p>
<p>除了能够给一个动态效果指定缓进出函数外，你现在可以指定每个属性的缓进出函数了。James Padolsey的<a href="http://james.padolsey.com/javascript/easing-in-jquery-1-4a2/">blog上</a>有更进一步的信息和演示。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"#clickme"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">click</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
  $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"div"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">animate</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">{</span>
    width<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(0, 153, 0);">[</span><span style="color: rgb(51, 102, 204);">"+=200px"</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(51, 102, 204);">"swing"</span><span style="color: rgb(0, 153, 0);">]</span><span style="color: rgb(51, 153, 51);">,</span>
    height<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(0, 153, 0);">[</span><span style="color: rgb(51, 102, 204);">"+=50px"</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(51, 102, 204);">"linear"</span><span style="color: rgb(0, 153, 0);">]</span><span style="color: rgb(51, 153, 51);">,</span>
  <span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(204, 0, 0);">2000</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
      $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 0, 102); font-weight: bold;">this</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">after</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"&lt;div&gt;Animation complete.&lt;/div&gt;"</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
  <span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<h4>事件 (Events)</h4>
<p><strong>新方法: jQuery.proxy()</strong> (<a href="http://api.jquery.com/jQuery.proxy/">jQuery.proxy() Documenation</a>, <a href="http://github.com/jquery/jquery/commit/66975de2d249643779e2b3daad0457f7f5f92508">Commit 1</a>, <a href="http://github.com/jquery/jquery/commit/1d2b1a57dae0b73b3d99197f73f4edb623b5574a">Commit 2</a>)</p>
<p>如果你需要保证一个函数内的”this”恒定地保持某个值, 你可以用<code>jQuery.proxy</code>获得一个相同作用域的函数。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript"><span style="color: rgb(0, 51, 102); font-weight: bold;">var</span> obj <span style="color: rgb(51, 153, 51);">=</span> <span style="color: rgb(0, 153, 0);">{</span>
  <span style="color: rgb(0, 0, 102);">name</span><span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(51, 102, 204);">"John"</span><span style="color: rgb(51, 153, 51);">,</span>
  test<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
    <span style="color: rgb(0, 0, 102);">alert</span><span style="color: rgb(0, 153, 0);">(</span> <span style="color: rgb(0, 0, 102); font-weight: bold;">this</span>.<span style="color: rgb(0, 0, 102);">name</span> <span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
    $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"#test"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">unbind</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"click"</span><span style="color: rgb(51, 153, 51);">,</span> obj.<span style="color: rgb(102, 0, 102);">test</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
  <span style="color: rgb(0, 153, 0);">}</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(51, 153, 51);">;</span>

$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"#test"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">click</span><span style="color: rgb(0, 153, 0);">(</span> jQuery.<span style="color: rgb(102, 0, 102);">proxy</span><span style="color: rgb(0, 153, 0);">(</span> obj<span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(51, 102, 204);">"test"</span> <span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p><strong>多个事件绑定</strong> (<a href="http://api.jquery.com/bind">.bind() 文档</a>)</p>
<p>你可以通过递入一个对象来一次性绑定元素的多个事件。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"div.test"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">bind</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">{</span>
  click<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 153, 0);">{</span>
    $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 0, 102); font-weight: bold;">this</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">addClass</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"active"</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
  <span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(51, 153, 51);">,</span>
  mouseenter<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 153, 0);">{</span>
    $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 0, 102); font-weight: bold;">this</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">addClass</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"inside"</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
  <span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(51, 153, 51);">,</span>
  mouseleave<span style="color: rgb(51, 153, 51);">:</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(0, 153, 0);">{</span>
    $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 0, 102); font-weight: bold;">this</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">removeClass</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"inside"</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
  <span style="color: rgb(0, 153, 0);">}</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p><strong>‘change’和’submit’事件规范化</strong> (<a href="http://api.jquery.com/change">Change 文档</a>, <a href="http://api.jquery.com/submit">Submit 文档</a>)</p>
<p>普通的或是即时的<code>change</code>和<code>submit</code>事件可以在各种浏览器上稳定工作了。我们覆盖了IE里的<code>change</code>和<code>submit</code>, 替换为与其他浏览器相同的事件。</p>
<p><strong>新的事件: ‘focusin’ and ‘focusout’</strong> (<a href="http://api.jquery.com/focusin/">.focusin() 文档</a>, <a href="http://api.jquery.com/focusout/">.focusout() 文档</a>, <a href="http://github.com/jquery/jquery/commit/03481a52c72e417b01cfeb499f26738cf5ed5839">Commit</a>)</p>
<p><code>focusin</code>和<code>focusout</code>在一般情况下等同于<code>focus</code>和<code>blur</code>, 但是多了向父元素传递的作用。如果你自己编写你的事件代理模式(TODO), 这个功能将对你有很大帮助。请注意对<code>focus</code>和<code>blur</code>使用<code>live()</code>方法将不会起作用; 在设计的时候我们根据 <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html">DOM事件规范</a>决定不使其向父元素传递事件。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"form"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">focusout</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span>event<span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
    <span style="color: rgb(0, 51, 102); font-weight: bold;">var</span> tgt <span style="color: rgb(51, 153, 51);">=</span> event.<span style="color: rgb(102, 0, 102);">target</span><span style="color: rgb(51, 153, 51);">;</span>
    <span style="color: rgb(0, 0, 102); font-weight: bold;">if</span> <span style="color: rgb(0, 153, 0);">(</span>tgt.<span style="color: rgb(102, 0, 102);">nodeName</span> <span style="color: rgb(51, 153, 51);">==</span> <span style="color: rgb(51, 102, 204);">"INPUT"</span> <span style="color: rgb(51, 153, 51);">&amp;&amp;</span> <span style="color: rgb(51, 153, 51);">!</span>tgt.<span style="color: rgb(102, 0, 102);">value</span><span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
        $<span style="color: rgb(0, 153, 0);">(</span>tgt<span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">after</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"<span>nothing here</span>"</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
    <span style="color: rgb(0, 153, 0);">}</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p><strong>所有的事件都可以成为即时事件</strong> (<a href="http://api.jquery.com/live">.live() 文档</a>)</p>
<p>除了<a href="http://api.jquery.com/ready">ready</a>, <a href="http://api.jquery.com/focus">focus</a> (用focusin), 和 <a href="http://api.jquery.com/blur">blur</a> (用focusout)以外, 所有能用<code>.bind()</code>绑定的事件都可以成为即时事件。</p>
<p>在<code>live()</code>所支持的事件里，我们对能够支持下面这几个额外的事件感到尤其骄傲。通过<code>.live()</code>里的事件代理, 1.4版实现了对<code>change</code>, <code>submit</code>, <code>focusin</code>, <code>focusout</code>, <code>mouseenter</code>, 以及<code>mouseleave</code>事件的跨浏览器支持。</p>
<p>注: 如果你需要即时的<code>focus</code>事件，你应该用<code>focusin</code>和<code>focusout</code>, 而不要用<code>focus</code>和<code>blur</code>, 因为就像前面提到的, <code>focus</code>和<code>blur</code>不向上传递。</p>
<p>还有, <code>live()</code>也接受数据对象作为参数了, 同<code>bind()</code>方法一样 (<a href="http://github.com/jquery/jquery/commit/71efbdd3b26f3a283f8d4bfdcc7b6343142027b9">Commit</a>)</p>
<p><strong>live/die也支持环境变量了</strong> (<a href="http://github.com/jquery/jquery/commit/30e760b63fd6d82f30833cd2864f245dd9594cd9">Commit</a>)</p>
<p>现在可以在绑定事件的时候给选择符指定一个环境。如果环境被指定了, 只有属于这个环境下的元素才会被绑定事件。在创建即时事件的时候, 元素本身不需要已经被定义, 但是环境必须被创建。</p>
<p><strong>确定ready事件至少含有<code>body</code>元素</strong> (<a href="http://github.com/jquery/jquery/commit/262fcf7b7b919da1564509f621cf7480a5d5572b">Commit</a>)</p>
<p>jQuery现在会检查<code>body</code>是不是存在，如果不存在，会对<code>body</code>进行轮流探询。</p>
<p><strong>在不需要手动处理内存溢出的非IE浏览器中, 卸载的速度提高了。</strong> (<a href="http://github.com/jquery/jquery/commit/f3474c00cd6d9e5fd61b6ef1562003e9986ad67d">Commit</a>)</p>
<h4>DOM操作 (Manipulation)</h4>
<p>在jQuery 1.4里一系列的DOM操作方法的性能都有巨大的提升。</p>
<p><strong><a href="http://api.jquery.com/append">.append()</a>, <a href="http://api.jquery.com/prepend">.prepend()</a>, <a href="http://api.jquery.com/before">.before()</a>, and <a href="http://api.jquery.com/after">.after()</a>的性能提高了。</strong></p>
<p><a rel="lightbox[69]" href="http://www.uxd2.com/wp-content/uploads/2010/01/05-perform-dom.jpg"><img width="500" height="375" alt="DOM嵌入的性能提高" src="http://www.uxd2.com/wp-content/uploads/2010/01/05-perform-dom.jpg" title="DOM嵌入的性能提高" class="alignnone size-full wp-image-78"></a></p>
<p><strong><a href="http://api.jquery.com/html">.html()</a>的性能提高到以前的3倍。</strong></p>
<p><a rel="lightbox[69]" href="http://www.uxd2.com/wp-content/uploads/2010/01/06-perform-html.jpg"><img width="500" height="375" alt=".html()的性能提高" src="http://www.uxd2.com/wp-content/uploads/2010/01/06-perform-html.jpg" title=".html()的性能提高" class="alignnone size-full wp-image-79"></a></p>
<p><strong>.remove()和.empty()的速度则达到以前的4倍.</strong></p>
<p><a rel="lightbox[69]" href="http://www.uxd2.com/wp-content/uploads/2010/01/07-perform-remove.jpg"><img width="500" height="375" alt=".remove() 和 .empty()的性能提高" src="http://www.uxd2.com/wp-content/uploads/2010/01/07-perform-remove.jpg" title=".remove() 和 .empty()的性能提高" class="alignnone size-full wp-image-80"></a></p>
<p><strong>新方法: .detach()</strong> (<a href="http://api.jquery.com/detach/">.detach() 文档</a>, <a href="http://github.com/jquery/jquery/commit/7a67f8897d3c2ed97254f0fdb969be14e77962d1">Commit</a>)</p>
<p><code>detach()</code>将一个元素从DOM里移除, 但是并不卸载关联的事件处理函数。这个方法可用于暂时性的将一个元素移除，执行相关操作，然后返回。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript"><span style="color: rgb(0, 51, 102); font-weight: bold;">var</span> foo <span style="color: rgb(51, 153, 51);">=</span> $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"#foo"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">click</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
    <span style="color: rgb(0, 102, 0); font-style: italic;">// 相关操作</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
foo.<span style="color: rgb(102, 0, 102);">detach</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
<span style="color: rgb(0, 102, 0); font-style: italic;">// foo保留了相关处理函数</span>
foo.<span style="color: rgb(102, 0, 102);">appendTo</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"body"</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p><strong>新的unwrap()方法</strong> (<a href="http://api.jquery.com/unwrap/">documentation</a>, <a href="http://github.com/jquery/jquery/commit/69e6e53555f21f07b534f1169298f7b33011bb4b">commit</a>)</p>
<p><code>unwrap()</code>方法拿到一个已知的父元素的子元素，然后将父元素用子元素替换。(译注: 将子元素从”包裹”里拿出来, 因名unwrap)。如此这般:</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="html4strict"><span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">body</span>&gt;</span>
    <span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">div</span>&gt;</span>
        <span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span>annie<span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span> <span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span>davey<span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span> <span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span>stevie<span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span>
    <span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">div</span>&gt;</span>
<span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">body</span>&gt;</span></pre>
</div>
</div>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">'div'</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">unwrap</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="html4strict"><span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">body</span>&gt;</span>
   <span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span>annie<span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span> <span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span>davey<span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span> <span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span>stevie<span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">p</span>&gt;</span>
<span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">body</span>&gt;</span></pre>
</div>
</div>
<p><strong>domManip方法里的缓存</strong> (<a href="http://github.com/jquery/jquery/commit/8db967e9d52407c8e76d81b9d472800667f6fa29">commit</a>)</p>
<p>jQuery会将<code>jQuery("&lt;div&gt;")</code>和<code>.after("&lt;div&gt;")</code>一类方法创建的节点记入缓存。这样, 对于利用这些方法, 使用字符串进行DOM操作的页面，性能将有极大的提高。</p>
<p><strong>无连接的节点间的before, after, replaceWith操作</strong> (<a href="http://github.com/jquery/jquery/commit/173c1477ae6efc4c2eeb7131ba0646c4e1323975">commit</a>)</p>
<p>现在你可以对还没有放置到DOM Tree上的节点进行<code>before</code>, <code>after</code>, 和<code>replaceWith</code>的操作了。意味着你可以先对节点进行复杂的操作, 待完成后再放到合适的DOM位置上。这样也能尽量避免操作过程中造成重新排版。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">jQuery<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"&lt;div&gt;"<span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">before</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"&lt;p&gt;Hello&lt;/p&gt;"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">appendTo</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"body"</span><span style="color: rgb(0, 153, 0);">)</span></span></pre>
</div>
</div>
<p><strong><code>.clone(true)</code> 也会复制关联数据</strong> (<a href="http://api.jquery.com/clone/">clone 文档</a>, <a href="http://github.com/jquery/jquery/commit/4b70f006f579fba24a882d80ca67f1971dbb4922">commit</a>)</p>
<p>1.3版中, <code>.clone(true)</code>虽然也是深度复制, 但是没有复制关联的数据。1.4版里，它则会复制数据, 同时还包括所有的事件。这点上和<code>jQuery.extend</code>在语义想同的, 所以普通对象和阵列会被复制, 但是自定义的对象则不会。</p>
<h4>位移 (Offset)</h4>
<p><strong>.offset( coords | Function )</strong> (<a href="http://api.jquery.com/offset/">.offset() 文档</a>, <a href="http://github.com/jquery/jquery/commit/daffb954e397bd5d9f8e9aaedab6c0baa9609e1e">commit</a>)</p>
<p>现在可以设置元素的位移了! 和所有的设置函数一样, <code>offset</code>也可以接受一个函数作为第二个参数。</p>
<h4>队列 (Queueing)</h4>
<p>队列经历了一次大修, 使用队列会比使用默认的<code>fx</code>更易掌握。</p>
<p><strong>新的 .delay() 方法</strong> (<a href="http://api.jquery.com/delay/">.delay() 文档</a>, <a href="http://github.com/jquery/jquery/commit/bbd933cbfe6d31a749cb336d7a84155ccfab247f">commit</a>)</p>
<p><code>.delay()</code>方法会根据参数滞后若干毫秒执行队列里剩下的对象。默认的它会使用”fx”队列。但你可以选择性的通过<code>delay</code>方法的第二个参数选择其他队列。(译注:每个队列都以一个名字识别。)</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"div"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">fadeIn</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">delay</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(204, 0, 0);">4000</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">fadeOut</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p><strong>队列里的<code>next</code></strong> (<a href="http://api.jquery.com/queue/">.queue() 文档</a>, <a href="http://github.com/jquery/jquery/commit/89b4bc53ca0ca3d4e5c80b94ce92b09cc34af8ef">commit</a>)</p>
<p>jQuery 1.4版里, 当队列里的一个函数被调用的时候，第一个参数会被设为另一个函数。当后者被调用的时候, 会自动排除队列里的下一个对象, 以此来推动队列到下一步。</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript">jQuery<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"div"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">queue</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"ajax"</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span>next<span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
  <span style="color: rgb(0, 51, 102); font-weight: bold;">var</span> self <span style="color: rgb(51, 153, 51);">=</span> <span style="color: rgb(0, 0, 102); font-weight: bold;">this</span><span style="color: rgb(51, 153, 51);">;</span>
  jQuery.<span style="color: rgb(102, 0, 102);">getJSON</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"/update"</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span>json<span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
    $<span style="color: rgb(0, 153, 0);">(</span>self<span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">html</span><span style="color: rgb(0, 153, 0);">(</span>json.<span style="color: rgb(102, 0, 102);">text</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
    next<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
  <span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(51, 153, 51);">;</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">queue</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"ajax"</span><span style="color: rgb(51, 153, 51);">,</span> <span style="color: rgb(0, 51, 102); font-weight: bold;">function</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span> <span style="color: rgb(0, 153, 0);">{</span>
  $<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 0, 102); font-weight: bold;">this</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">fadeIn</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span>
<span style="color: rgb(0, 153, 0);">}</span><span style="color: rgb(0, 153, 0);">)</span><span style="color: rgb(51, 153, 51);">;</span></pre>
</div>
</div>
<p><strong>.clearQueue()</strong> (<a href="http://api.jquery.com/clearQueue/">clearQueue 文档</a>, <a href="http://github.com/jquery/jquery/commit/d857315967a1cc07b73924bbdf2eb12f4f910c45">commit</a>)</p>
<p>队列可以被清空了。这个方法会移除队列里所有未执行的函数, 但不会移除正在运行的函数。无参数的情况下调用<code>.clearQueue()</code>方法将会清空默认的”fx”队列。</p>
<h4>选择符 (Selectors)</h4>
<p><strong>“#id p”效率更高</strong> (<a href="http://github.com/jeresig/sizzle/commit/c5c18ae5f17f11b39b7f261633e4bfc5ef3e99d7">commit</a>)</p>
<p>所有以ID开头的选择符都得到了优化, 能够在瞬间得到返回值。所有以ID为开头的选择符速度将一直快于其他选择符。</p>
<h4>页面遍访 (Traversing)</h4>
<p><strong>.index(), .index(String)</strong> (<a href="http://api.jquery.com/index/">index 文档</a>, <a href="http://github.com/jquery/jquery/commit/ffd457d4561eb1a6653aaef90f92a3b3010b9139">commit</a>)</p>
<p><code>.index()</code> 方法经过重写, 变得更加直观和灵活。</p>
<p>你可以获得一个元素相对于同父元素的指数:</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript"><span style="color: rgb(0, 102, 0); font-style: italic;">// 计算第一个 &lt;li class="current"&gt; 元素在它所有的同父元素中的指数:</span>
$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"li.current"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">index</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(0, 153, 0);">)</span></pre>
</div>
</div>
<p>你也可以获得一个元素在一个jQuery元素集合中的指数, 这个集合可以用一个选择符或者是一个DOM元素来指定:</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="javascript"><span style="color: rgb(0, 102, 0); font-style: italic;">// 计算这个 &lt;h3 id="more-info"&gt; 元素在页面上所有 &lt;h3&gt; 元素里的指数:
$<span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"#more-info"</span><span style="color: rgb(0, 153, 0);">)</span>.<span style="color: rgb(102, 0, 102);">index</span><span style="color: rgb(0, 153, 0);">(</span><span style="color: rgb(51, 102, 204);">"h3"</span><span style="color: rgb(0, 153, 0);">)</span>

</span></pre>
</div>
</div>
<p><strong>新的.has()方法</strong> (<a href="http://api.jquery.com/has/">has 文档</a>, <a href="http://github.com/jquery/jquery/commit/4e27f17007c2329e31b449e61bb31197b90a37f1">commit</a>)</p>
<p>这个方法相当于选择符里的<code>:has()</code>过滤法。它拿到一个jQuery集合,返回含有指定选择符的元素。</p>
<p><strong>新的 .nextUntil(), .prevUntil(), .parentsUntil() 方法</strong> (<a href="http://api.jquery.com/nextUntil/">.nextUntil() 文档</a>, <a href="http://api.jquery.com/prevUntil/">.prevUntil() 文档</a>, <a href="http://api.jquery.com/parentsUntil/">.parentsUntil() 文档</a>, <a href="http://github.com/jquery/jquery/commit/2b481b93cfca62f95aa7005e7db651456fa08e65">commit</a>)</p>
<p>新的”until”方法类似于<code>.nextAll()</code>, <code>.prevAll()</code>, 和<code>.parents()</code>。区别是可以用一个选择符来停止元素探索。</p>
<p><strong>.add(String, Element)</strong> (<a href="http://jquery14.com/day-01/%3C/p%3E%3Cp%3Ehttp://api.jquery.com/add/%3C/p%3E%3Cp%3E">.add() 文档</a>, <a href="http://jquery14.com/day-01/%3C/p%3E%3Cp%3Ehttp://github.com/jquery/jquery/commit/b0fe380cf89564305646bbd55d1fd7bd210fd591%3C/p%3E%3Cp%3E">commit</a>)</p>
<p>可以给<code>.add()</code>方法指定环境了。这个功能可以用于在一个调用链中加入和操作额外元素(比如Ajax请求里返回的新元素)。</p>
<p><strong>.closest(filter, DOMElement)</strong> (<a href="http://api.jquery.com/closest/">.closest() 文档</a>, <a href="http://github.com/jquery/jquery/commit/d6991fa273515a8503692324499edcc71b5c3f64">commit</a>)</p>
<p>可以通过<code>closest</code>方法的第2个参数设置一个<code>DOMElement</code>环境。给<code>closest</code>设置一个环境一般能够提高这个方法的运行速度。这个优化也适用<code>live()</code>, 因为这个方法内部调用了<code>closest()</code>。</p>
<h4>常用工具 (Utilities)</h4>
<p><strong>jQuery.isEmptyObject()</strong> (<a href="http://api.jquery.com/jQuery.isEmptyObject/">jQuery.isEmptyObject() 文档</a>, <a href="http://github.com/jquery/jquery/commit/a38a5cd531a328319f8b7f3f33a84044b54591ce">commit</a>)</p>
<p>如果对象,em&gt;没有任何属性, 该方法将返回<code>true</code>。<code>jQuery.isEmptyObject()</code>方法不对参数进行任何检查, 所以请保证参数是一个对象。</p>
<p><strong>jQuery.isPlainObject()</strong> (<a href="http://api.jquery.com/jQuery.isPlainObject/">jQuery.isPlainObject()</a>, <a href="http://github.com/jquery/jquery/commit/4b55e94d0849568a2fd121952f13a9d6571c731f">commit</a> )</p>
<p>如果一个对象是通过字符创建的(译注:{}),<code>jQuery.isPlainObject()</code>返回<code>true</code>; 如果对象是其他类别的对象(译注:如new Object())或者是基本类型, 则返回<code>false</code>。</p>
<p><strong>jQuery.contains()</strong> (<a href="http://api.jquery.com/jQuery.contains/">jQuery.contains() 文档</a>, <a href="http://github.com/jquery/jquery/commit/4e27f17007c2329e31b449e61bb31197b90a37f1">commit</a>)</p>
<p>如果两个参数都是DOM节点，并且第二个节点是嵌套在第一个节点内部的话, <code>jQuery.contains()</code>返回<code>true</code>。反之返回<code>false</code>。</p>
<p><strong>jQuery.noop</strong> (<a href="http://api.jquery.com/jQuery.noop/">jQuery.noop() 文档</a>, <a href="http://github.com/jquery/jquery/commit/6cb2945837ccca55204191a8e7a70b2b2486c28e">commit</a>)</p>
<p>是个空的函数, 可以用在必须要有一个函数的情况下。(译注: noop是No Operation的意思。)</p>
<p><strong>jQuery.unique()</strong> (<a href="http://api.jquery.com/jQuery.unique/">jQuery.unique() 文档</a>)</p>
<p>jQuery 1.4版中, <code>jQuery.unique()</code>方法返回结果里的元素是按照他们在页面里的顺序排序的。由于在创建jQuery集合的时候jQuery使用<code>jQuery.unique()</code>方法, 所以jQuery方法返回的集合也是按照他们在页面里的顺序排列的。</p>
<h4>其他 (Miscellaneous)</h4>
<p><strong>jQuery.browser以浏览器引擎为中心</strong> (<a href="http://api.jquery.com/jQuery.browser/">jQuery.browser 文档</a>, <a href="http://jquery14.com/day-01/%3Cbr%20/%3Ehttp://github.com/jquery/jquery/commit/ffb1867a4364ea65e60dad3469e8c8eb420ebcac">commit</a>)</p>
<p>例如, 你可以通过<code>jQuery.browser.webkit</code>探测引擎是否是Webkit。</p>
<p><strong>改进了对<code>applets</code>的处理</strong> (<a href="http://github.com/jquery/jquery/commit/59802928566b6be3a66d65e77c2418fff37e6f5f">commit 1</a>, <a href="http://github.com/jquery/jquery/commit/3ec2f1aef6b137d0f639e2fc53f95352d24b9d90">commit 2</a>)</p>
<p>jQuery不再试图在Java applets上绑定事件或是数据了(绑定事件或是数据会出现错误)。</p>
<p><strong>不再使用arguments.callee</strong> (<a href="http://github.com/jquery/jquery/commit/985856b823b1648bffc3fd63c1faf836d0ddaf7c">commit</a>)</p>
<p>为了顺应<a href="http://code.google.com/p/google-caja/">Caja</a>的要求, 同时也因为即将开始应用的ECMAScript 5规范里将其标记为陈旧, 我们将jQuery核心中所有用到<code>arguments.callee</code>的代码都移除了。</p>
<p><strong>用Closure Compiler替换了YUI Min</strong> (<a href="http://github.com/jquery/jquery/commit/3fd62eae9df3159fc238a515bb748140a942313d">commit</a>)</p>
<h4>内部重组 (Internal Reorganization)</h4>
<p>在1.4版的开发过程中的一个重点是要建立一个更易读, 更易懂的代码库。为了达到这个目标我们树立了一系列编写代码规范的向导。</p>
<p>下面是一些主要的变化:</p>
<ul>
<li>旧的’core.js’文件被分成了’attribute.js’, ‘css.js’, ‘data.js’, ‘manipulation.js’, ‘traversing.js’, and ‘queue.js’.</li>
<li>ready事件被移入了’core.js’ (因为它是jQuery的一个基本组成之一)。</li>
<li>大部分核心代码都符合新的<a href="http://docs.jquery.com/JQuery_Core_Style_Guidelines">代码规范</a>.</li>
<li>css和属性的逻辑被划分开来, 不再如以往相互缠绕。</li>
</ul>
<h4>测试 (Testing)</h4>
<p>jQuery 1.4版发布过程中我们<a href="http://dev.jquery.com/report/34">修复了207个问题</a> (比较之下1.3版里有97个修复)。</p>
<p>jQuery 1.4.此外, 测试的数量从jQuery 1.3.2中的1504例升到了1.4中的3060例。</p>
<p>所有测试都在主要浏览器里完全通过了。(Safari 3.2, Safari 4, Firefox 2, Firefox 3, Firefox 3.5, IE 6, IE 7,<br />
IE 8, Opera 10.10, and Chrome)</p>
<p><a rel="lightbox[69]" href="http://www.uxd2.com/wp-content/uploads/2010/01/08-test.jpg"><img width="500" height="277" alt="jQuery 1.4 测试结果" src="http://www.uxd2.com/wp-content/uploads/2010/01/08-test.jpg" title="jQuery 1.4 测试结果" class="alignnone size-full wp-image-81"></a></p>
<h3><a name="backwards"></a></h3>
<p>我们尽量试图减小jQuery 1.4对大规模升级可能造成的麻烦 &ndash; 保持所有公开函数的签名不变。即使如此, 请通读下面的列表以保证你对可能对你的应用造成问题的变更。</p>
<ul>
<li><a href="http://api.jquery.com/add">.add()</a>不再简单的将结果串联到一起, 结果将会被混合到一起, 然后根据他们在页面里的顺序排列。</li>
<li><a href="http://api.jquery.com/clone">.clone(true)</a>将复制事件和数据, 而不仅是事件。</li>
<li><a href="http://api.jquery.com/jQuery.data">jQuery.data(elem)</a> 不再返回<code>id</code>, 取而代之的是元素的对象缓存。</li>
<li><a href="http://api.jquery.com/jQuery">jQuery()</a> (无参数) 不再自动转换成<a href="http://api.jquery.com/jQuery">jQuery(document)</a>了。</li>
<li>通过<a href="http://api.jquery.com/val">.val(“…”)</a>获得一个<code>option</code>或一个<code>checkbox</code>的值不再有歧义(将总是根据<code>value</code>属性选择, 而不是根据<code>text</code>的值)。(<a href="http://github.com/jquery/jquery/commit/f298cce100c6fe23840ac95e66aaea9cb2bfb447">Commit</a>)</li>
<li><a href="http://api.jquery.com/jQuery.browser">jQuery.browser.version</a>现在将返回引擎的版本.</li>
<li>现在起将对引入的JSON更严格, 如果JSON的格式不符将会报错。如果你需要对不符合JSON严格格式的Javascript进行估值, 你必须设置请求的文件类型为纯文本, 然后用<code>eval()</code>来对内容估值。</li>
<li>参数序列化默认会按照PHP/Rails的风格进行。你可以通过<code>jQuery.ajaxSettings.traditional = true;</code>来切换到旧的序列化方式。你也可以针对个别请求进行切换, 在调用<a href="http://api.jquery.com/jQuery.ajax">jQuery.ajax</a>的时候递入<code>{traditional: true}</code></li>
<li>内部的jQuery.className被移除了。</li>
<li><a href="http://api.jquery.com/jQuery.extend">jQuery.extend(true, …)</a>不再扩展复杂对象或是阵列。(TODO)</li>
<li>如果一个<a href="http://api.jquery.com/jQuery.ajax">Ajax请求</a>没有指定dataType, 而返回的数据类型是”text/javascript”, 那么回复将会被执行。之前, 必须明确的指定dataType。</li>
<li>设置<a href="http://api.jquery.com/jQuery.ajax">Ajax 请求</a>的”ifModified”属性会将ETags纳入考虑。</li>
</ul>
<p>我们还针对1.4版中可能造成问题的变更编写了一个向后兼容的<a href="http://github.com/jquery/jquery-compat-1.3">插件</a>。如果你升级到1.4以后出现问题, 可以在引入1.4版的文件之后引入这个插件。</p>
<p>如何使用这个插件:</p>
<div class="wp_syntax">
<div class="code">
<pre style="font-family: monospace;" class="html4strict"><span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">script</span> <span style="color: rgb(0, 0, 102);">src</span><span style="color: rgb(102, 204, 102);">=</span><span style="color: rgb(255, 0, 0);">"http://code.jquery.com/jquery.js"</span>&gt;&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">script</span>&gt;</span>
<span style="color: rgb(0, 153, 0);">&lt;<span style="color: rgb(0, 0, 0); font-weight: bold;">script</span> <span style="color: rgb(0, 0, 102);">src</span><span style="color: rgb(102, 204, 102);">=</span><span style="color: rgb(255, 0, 0);">"http://code.jquery.com/jquery.compat-1.3.js"</span>&gt;&lt;<span style="color: rgb(102, 204, 102);">/</span><span style="color: rgb(0, 0, 0); font-weight: bold;">script</span>&gt;</span></pre>
</div>
</div>
<h3>原始数据和测试页面</h3>
<p>性能测试中我们使用了下列测试套包:</p>
<ul>
<li><a href="http://ejohn.org/files/jquery1.4/slick/?type=attr">Attributes</a></li>
<li><a href="http://ejohn.org/files/jquery1.4/slick/?type=class">Class</a></li>
<li><a href="http://ejohn.org/files/jquery1.4/slick/?type=dom">DOM Manipulation</a></li>
<li><a href="http://ejohn.org/files/jquery1.4/slick/?type=empty">Empty/Remove</a></li>
<li>Function Call Profiling: <a href="http://ejohn.org/files/jquery-profile.html">1.3.2</a> <a href="http://ejohn.org/files/jquery-profile-14.html">1.4</a>.</li>
</ul>
<p>结果的原始数据 (所有的数据都是 1.3.2 vs. 1.4):</p>
<pre>函数调用的次数
547    3
760    3
500    200
896    399
23909    299
307    118
28955    100
28648    201
1662    593

DOM嵌入
558    317
1079    624
1079    516
1155    829
436    332
196    194
243    169

HTML
116    46
281    78
313    78
234    63
134    43
43    42
91    27

CSS/属性
703    370
1780    1250
1765    1250
1157    749
629    498
346    184
333    161

CSS
114    52
203    93
118    93
109    47
116    54
58    24
54    22

CSS类
553    138
1578    546
1515    501
1033    327
769    298
229    80
173    41

移除/清空
3298    286
9030    2344
7921    1703
5282    1266
2898    303
1166    140
1034    122</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/677.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用户上传头像，等比例缩放</title>
		<link>http://www.artcss.com/archives/602.html</link>
		<comments>http://www.artcss.com/archives/602.html#comments</comments>
		<pubDate>Mon, 08 Feb 2010 13:16:00 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[个人随笔]]></category>
		<category><![CDATA[头像]]></category>
		<category><![CDATA[自适应]]></category>

		<guid isPermaLink="false">http://blog.artskin.cn/?p=602</guid>
		<description><![CDATA[其实关于用户上传头像大小问题早就有了比较完美的解决办法，那就是再上传时通过裁切来实现。 最近做一个专题，用裁切有点大材小用，而且着急上线，就写了个简单js来满足头像自适应预留位置大小。 具体要求如下： 1、当用户上传的头像宽和高均小于指定大小（200X150）时，图片按实际大小显示，且水平垂直居中 2、当用户上传的头像宽或高大于指定大小（200X150）时，分两种情况： 如果比3:4扁的话，则宽度缩为200，高度根据宽度自适应，且水平垂直居中。 如果比3:4窄的话，则高度缩为150，宽度根据高度自适应，且水平垂直居中。 用到的javascript代码如下[jQuery版]： Download script.js1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 $&#40;document&#41;.ready&#40;function&#40;&#41; &#123; $&#40;&#34;#tt a&#34;&#41;.click&#40;function&#40;&#41;&#123; [...]]]></description>
			<content:encoded><![CDATA[<p>其实关于用户上传头像大小问题早就有了比较完美的解决办法，那就是再上传时通过裁切来实现。</p>
<p>最近做一个专题，用裁切有点大材小用，而且着急上线，就写了个简单js来满足头像自适应预留位置大小。</p>
<p>具体要求如下：</p>
<p>1、当用户上传的头像宽和高均小于指定大小（200X150）时，<span id="more-602"></span>图片按实际大小显示，且水平垂直居中</p>
<p>2、当用户上传的头像宽或高大于指定大小（200X150）时，分两种情况：</p>
<ul>
<li>如果比3:4扁的话，则宽度缩为200，高度根据宽度自适应，且水平垂直居中。</li>
<li>如果比3:4窄的话，则高度缩为150，宽度根据高度自适应，且水平垂直居中。</li>
</ul>
<h5>用到的javascript代码如下[jQuery版]：</h5>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left2">Download <a href="http://www.artcss.com/wp-content/plugins/wp-codebox/wp-codebox.php?p=602&amp;download=script.js">script.js</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p60212"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code" id="p602code12"><pre class="javascript" style="font-family:Verdana;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #990000;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#tt a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#tt a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;on&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;on&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.userbox img&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> userPic <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.&quot;</span><span style="color: #339933;">+</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	userPic.<span style="color: #990000;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> userPic.<span style="color: #990000;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	<span style="color: #999999;">//获取当前图片的ID</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#yuanshi&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#yuanshi&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#yuanshi&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">show</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> userW <span style="color: #339933;">=</span> userPic.<span style="color: #990000;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> userH <span style="color: #339933;">=</span> userPic.<span style="color: #990000;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> bool <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>userW<span style="color: #339933;">&lt;</span><span style="color: #ff0000;">200</span> <span style="color: #339933;">&amp;&amp;</span> userH<span style="color: #339933;">&lt;</span><span style="color: #ff0000;">150</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>	<span style="color: #999999;">//判断如果图片高宽均小于指定大小时的情况</span>
		userW <span style="color: #339933;">=</span> userW<span style="color: #339933;">;</span>
		userH <span style="color: #339933;">=</span> userH<span style="color: #339933;">;</span>
		bool <span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>userH<span style="color: #339933;">/</span>userW <span style="color: #339933;">&lt;</span> <span style="color: #ff0000;">3</span><span style="color: #339933;">/</span><span style="color: #ff0000;">4</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			userPic.<span style="color: #990000;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
			userPic.<span style="color: #990000;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;height&quot;</span><span style="color: #339933;">,</span><span style="color: #ff0000;">150</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>userH <span style="color: #339933;">&lt;</span> <span style="color: #ff0000;">150</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>	<span style="color: #999999;">//设置图片垂直居中</span>
		<span style="color: #003366; font-weight: bold;">var</span> userTop<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>bool<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			userTop <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">150</span> <span style="color: #339933;">-</span> userH<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #ff0000;">2</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
			userH  <span style="color: #339933;">=</span> userH<span style="color: #339933;">*</span><span style="color: #ff0000;">200</span><span style="color: #339933;">/</span>userW<span style="color: #339933;">;</span>
			userTop <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">150</span> <span style="color: #339933;">-</span> userH<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #ff0000;">2</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		userPic.<span style="color: #990000;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;margin-top&quot;</span><span style="color: #339933;">,</span>userTop<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
		userPic.<span style="color: #990000;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;margin-top&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;0px&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#tt a:first&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;on&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.userbox img:not(:first)&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #990000;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h5>点击下面“运行”直接查看效果</h5>
<div class="runcode">
<p><textarea name="runcode" class="runcode_text" id="runcode_opFxAi">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=gb2312&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;前端思考&quot; /&gt;
&lt;meta name=&quot;keywords&quot; content=&quot;前端思考&quot; /&gt;
&lt;title&gt;用户上传头像，大小自适应预留位置：前端思考&lt;/title&gt;
&lt;script src=&quot;http://www.artcss.com/js/jq_1.4.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;style&gt;
*{margin:0;padding:0px;}
a{text-decoration:none;color:#000}
body{padding:30px;}
.userbox{width:200px;height:150px;float:left;margin:10px;overflow:hidden;text-align:center;background:#ddd;border:2px dashed #333}
.userbox img{background:#ddd}
#tt{width:330px;float:left;}
#tt a{display:block;width:330px;cursor:pointer;margin-top:10px;background:#ccc;}
#tt a:hover,#tt span.on{background:#f00;}
h5{clear:both;}
.right{float:left;border:1px solid #666;padding:3px;}
&lt;/style&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
$(&quot;#tt a&quot;).click(function(){
	$(&quot;#tt a&quot;).removeClass(&quot;on&quot;);
	$(this).addClass(&quot;on&quot;);
	$(&quot;.userbox img&quot;).hide();
	var userPic = $(&quot;.&quot;+$(this).attr(&quot;id&quot;));
	userPic.show();
	var url = userPic.attr(&quot;src&quot;);
	$(&quot;#yuanshi&quot;).attr(&quot;src&quot;,url);
	$(&quot;#yuanshi&quot;).hide();
	$(&quot;#yuanshi&quot;).show(&quot;slow&quot;);
	var userW = userPic.width();
	var userH = userPic.height();
	var bool = false;
	if(userW&lt;200 &amp;&amp; userH&lt;150 ){
		userW = userW;
		userH = userH;
		bool =true;
	}else{
		if(userH/userW &lt; 3/4){
			userPic.css(&quot;width&quot;,200);
		}else{
			userPic.css(&quot;height&quot;,150);
		}
	}
	if(userH &lt; 150){
		var userTop;
		if(bool){
			userTop = (150 - userH)/2;
		}else{
			userH  = userH*200/userW;
			userTop = (150 - userH)/2;
		}
		userPic.css(&quot;margin-top&quot;,userTop);
	}else{
		userPic.css(&quot;margin-top&quot;,&quot;0px&quot;);
	}
});
$(&quot;#tt a:first&quot;).addClass(&quot;on&quot;);
$(&quot;.userbox img:not(:first)&quot;).hide();
});
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h5&gt;头像指定大小为200*150&lt;/h5&gt;
&lt;div id=&quot;tt&quot;&gt;
	&lt;a id=&quot;tab1&quot; href=&quot;javascript:;&quot; rel=&quot;http://www.artskin.cn/blog/wp-content/uploads/2010/02/head4.jpg&quot;&gt;头像一[宽高完全符合规定大小]&lt;/a&gt;
	&lt;a id=&quot;tab2&quot; href=&quot;javascript:;&quot; rel=&quot;http://www.artskin.cn/blog/wp-content/uploads/2010/02/head2.jpg&quot;&gt;头像二[宽高均小于指定大小]&lt;/a&gt;
	&lt;a id=&quot;tab3&quot; href=&quot;javascript:;&quot; rel=&quot;http://www.artskin.cn/blog/wp-content/uploads/2010/02/head1.jpg&quot;&gt;头像三[宽高均大于指定大小，且高大于宽]&lt;/a&gt;
	&lt;a id=&quot;tab4&quot; href=&quot;javascript:;&quot; rel=&quot;http://www.artskin.cn/blog/wp-content/uploads/2010/02/head3.jpg&quot;&gt;头像四[宽高均小于指定大小，且宽大于高]&lt;/a&gt;
&lt;/div&gt;
&lt;div class=&quot;userbox&quot;&gt;
	&lt;img class=&quot;tab1&quot; src=&quot;http://www.artskin.cn/blog/wp-content/uploads/2010/02/head4.jpg&quot; alt=&quot;&quot; /&gt;
	&lt;img class=&quot;tab2&quot; src=&quot;http://www.artskin.cn/blog/wp-content/uploads/2010/02/head2.jpg&quot; alt=&quot;&quot; /&gt;
	&lt;img class=&quot;tab3&quot; src=&quot;http://www.artskin.cn/blog/wp-content/uploads/2010/02/head1.jpg&quot; alt=&quot;&quot; /&gt;
	&lt;img class=&quot;tab4&quot; src=&quot;http://www.artskin.cn/blog/wp-content/uploads/2010/02/head3.jpg&quot; alt=&quot;&quot; /&gt;
&lt;/div&gt;
&lt;h5&gt;图片原始大小为&lt;/h5&gt;
&lt;div class=&quot;right&quot;&gt;
	&lt;img id=&quot;yuanshi&quot; src=&quot;http://www.artskin.cn/blog/wp-content/uploads/2010/02/head4.jpg&quot; alt=&quot;&quot; /&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</textarea></p>
<p><input type="button" value="运行" class="runcode_button" onclick="runcode_open_new('runcode_opFxAi');"/> <input type="button" value="复制" class="runcode_button" onclick="runcode_copy('runcode_opFxAi');"/> 提示：你可以先修改部分代码再运行。</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/602.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10个Js的小型库，效果真的很棒[转]</title>
		<link>http://www.artcss.com/archives/588.html</link>
		<comments>http://www.artcss.com/archives/588.html#comments</comments>
		<pubDate>Mon, 08 Feb 2010 01:33:50 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[js小型库]]></category>

		<guid isPermaLink="false">http://blog.artskin.cn/?p=588</guid>
		<description><![CDATA[这些列举的网站，站内还有大量的效果，希望大家多去找找，对于研究的朋友来说，更是很棒的源码参考。第5款的东东，很强很震撼… 1、$fx() 简介：$fx()是一个轻量级的动画库，一些复杂的动画，可以由多个简单的动画效果进行组合，但是提供的是混淆压缩过的代码，对于研究动画源码的朋友可能特别不爽 API：http://fx.inetcat.com/manuals.php 主页:http://fx.inetcat.com/ 2、JSTweener 简介：原始大小14K，支持大多数的动画特效 演示地址：http://svn.coderepos.org/share/l … es/transitions.html 主页地址：http://coderepos.org/share/wiki/JSTweener 3、FX 2.0 简介：代码清晰，支持多种形变动画，而且2.0版本在不局限于px单位，支持了em, %, 演示地址：http://www.ryanmorr.com/tests/fx2/ 主页地址：http://ryanmorr.com/archives/fx- … animation-framework 4、JsCharts 简介：用js生成图表，包括柱状图，饼状图，流线图 演示地址：http://www.jscharts.com/examples 主页地址：http://www.jscharts.com/ 5、Raphael 简介：也许你看了效果后会觉得唉，这有什么特别的，但是查看它的源码的时候，你会被震到，不信就去看看呗，里边的效果实在是太神奇了，虽然目前你根本用不上…. 演示地址：http://raphaeljs.com/dragon.html 主页地址：http://raphaeljs.com/dragon.html 6、Reflection.js 简介：倒影实现,如果是在个人项目中，还是可以用得上的，唉，感叹，现在是可供选择的效果太充足了，而实际真正用到项目中的确是寥寥无几，只能这么说，就目前的web项目在交互方面 只能打个不及格。现在貌似国外都是研究者，而我们只是应用者，而且应用得还不到位。 主页地址：http://cow.neondragon.net/stuff/reflection/ 脚本地址:&#160;&#160;http://cow.neondragon.net/stuff/reflection/reflection.js (27K) 7、leigeber 简介：准确的说 这不是一个库，而是一些效果集，但是这对于我们来说却是非常实用的，每个效果都在3K左右， 效果列表：http://www.leigeber.com/category/javascript/ 主页地址：http://www.leigeber.com/ 8、Shortcuts.js 简介：在web2.0+时代，web应用中的快捷键开始大量使用,而且开始流行起来，google reader 和 Gmail等应用更是引领这一潮流，但是作为开发者，搞定键盘的绑定却不是一件轻松的事情，而shortCuts则以更优的方式解决了这一问题。 演示地址：http://www.openjs.com/scripts/events/keyboard_shortcuts/ 主页地址：http://www.openjs.com/scripts/events/keyboard_shortcuts/ 9、Amberjack (4K) 简介：这个效果我觉得用在商城上 挺合适的，比如一些打折信息，热卖商品等，只是网站官方极力推销的，用这种方式到不失为一种好方法，当然反对的声音肯定挺多的… 演示地址：http://amberjack.org/skins/custo … skinId=black_beauty 主页地址：http://amberjack.org 10、Blackbird (10K) [...]]]></description>
			<content:encoded><![CDATA[<p>这些列举的网站，站内还有大量的效果，希望大家多去找找，对于研究的朋友来说，更是很棒的源码参考。<span id="more-588"></span>第5款的东东，很强很震撼…</p>
<p><strong>1、$fx()</strong><br />
简介：$fx()是一个轻量级的动画库，一些复杂的动画，可以由多个简单的动画效果进行组合，但是提供的是混淆压缩过的代码，对于研究动画源码的朋友可能特别不爽<br />
API：<a target="_blank" href="http://fx.inetcat.com/manuals.php">http://fx.inetcat.com/manuals.php</a><br />
主页:<a target="_blank" href="http://fx.inetcat.com/">http://fx.inetcat.com/</a></p>
<p><strong>2、JSTweener</strong><br />
简介：原始大小14K，支持大多数的动画特效<br />
演示地址：<a target="_blank" href="http://svn.coderepos.org/share/lang/javascript/jstweener/trunk/examples/transitions.html">http://svn.coderepos.org/share/l … es/transitions.html</a><br />
主页地址：<a target="_blank" href="http://coderepos.org/share/wiki/JSTweener">http://coderepos.org/share/wiki/JSTweener</a><br />
<span id="more-1178"></span><br />
<strong>3、FX 2.0</strong><br />
简介：代码清晰，支持多种形变动画，而且2.0版本在不局限于px单位，支持了em, %,<br />
演示地址：<a target="_blank" href="http://www.ryanmorr.com/tests/fx2/">http://www.ryanmorr.com/tests/fx2/</a><br />
主页地址：<a target="_blank" href="http://ryanmorr.com/archives/fx-2-0-the-full-featured-animation-framework">http://ryanmorr.com/archives/fx- … animation-framework</a></p>
<p><strong>4、JsCharts<br />
</strong>简介：用js生成图表，包括柱状图，饼状图，流线图<br />
演示地址：<a target="_blank" href="http://www.jscharts.com/examples">http://www.jscharts.com/examples</a><br />
主页地址：<a target="_blank" href="http://www.jscharts.com/">http://www.jscharts.com/</a></p>
<p><strong>5、Raphael</strong><br />
简介：也许你看了效果后会觉得唉，这有什么特别的，但是查看它的源码的时候，你会被震到，不信就去看看呗，里边的效果实在是太神奇了，虽然目前你根本用不上….<br />
演示地址：<a target="_blank" href="http://raphaeljs.com/dragon.html">http://raphaeljs.com/dragon.html</a><br />
主页地址：<a target="_blank" href="http://raphaeljs.com/dragon.html">http://raphaeljs.com/dragon.html</a></p>
<p><strong>6、Reflection.js<br />
</strong>简介：倒影实现,如果是在个人项目中，还是可以用得上的，唉，感叹，现在是可供选择的效果太充足了，而实际真正用到项目中的确是寥寥无几，只能这么说，就目前的web项目在交互方面 只能打个不及格。现在貌似国外都是研究者，而我们只是应用者，而且应用得还不到位。<br />
主页地址：<a target="_blank" href="http://cow.neondragon.net/stuff/reflection/">http://cow.neondragon.net/stuff/reflection/</a><br />
脚本地址:&nbsp;&nbsp;<a target="_blank" href="http://cow.neondragon.net/stuff/reflection/reflection.js">http://cow.neondragon.net/stuff/reflection/reflection.js</a> (27K)</p>
<p><strong>7、leigeber</strong><br />
简介：准确的说 这不是一个库，而是一些效果集，但是这对于我们来说却是非常实用的，每个效果都在3K左右，<br />
效果列表：<a target="_blank" href="http://www.leigeber.com/category/javascript/">http://www.leigeber.com/category/javascript/</a><br />
主页地址：<a target="_blank" href="http://www.leigeber.com/">http://www.leigeber.com/</a></p>
<p><strong>8、Shortcuts.js</strong><br />
简介：在web2.0+时代，web应用中的快捷键开始大量使用,而且开始流行起来，google reader 和 Gmail等应用更是引领这一潮流，但是作为开发者，搞定键盘的绑定却不是一件轻松的事情，而shortCuts则以更优的方式解决了这一问题。<br />
演示地址：<a target="_blank" href="http://www.openjs.com/scripts/events/keyboard_shortcuts/">http://www.openjs.com/scripts/events/keyboard_shortcuts/</a><br />
主页地址：<a target="_blank" href="http://www.openjs.com/scripts/events/keyboard_shortcuts/">http://www.openjs.com/scripts/events/keyboard_shortcuts/</a></p>
<p><strong>9、Amberjack (4K)</strong><br />
简介：这个效果我觉得用在商城上 挺合适的，比如一些打折信息，热卖商品等，只是网站官方极力推销的，用这种方式到不失为一种好方法，当然反对的声音肯定挺多的…<br />
演示地址：<a target="_blank" href="http://amberjack.org/skins/customize/?travel=1&amp;tourId=AJTour&amp;skinId=black_beauty">http://amberjack.org/skins/custo … skinId=black_beauty</a><br />
主页地址：<a target="_blank" href="http://amberjack.org/">http://amberjack.org</a></p>
<p><strong>10、Blackbird (10K)<br />
</strong>简介：alert()的替代方案，现如今耳目下通常开发者都是使用自己制造的弹出层对话框，但是这款的设计思路确是仿照一些软件的控制台日志的方式，把信息都集中于一个面板上，对于用户来说，这其实是一件好事，对自己的操作所产生的结果至少一目了然，web 应用发展新时代，这个东东会成为一个趋势吧。对了，还支持快捷键.<br />
演示地址：<a target="_blank" href="http://www.gscottolson.com/blackbirdjs/">http://www.gscottolson.com/blackbirdjs/</a><br />
主页地址：<a target="_blank" href="http://www.gscottolson.com/">http://www.gscottolson.com/</a></p>
<p>原文地址：http://bbs.blueidea.com/thread-2943411-1-1.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/588.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>让IE6更快的走向灭亡[转]</title>
		<link>http://www.artcss.com/archives/569.html</link>
		<comments>http://www.artcss.com/archives/569.html#comments</comments>
		<pubDate>Sat, 06 Feb 2010 09:09:17 +0000</pubDate>
		<dc:creator>Artcss</dc:creator>
				<category><![CDATA[个人随笔]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[灭亡]]></category>

		<guid isPermaLink="false">http://blog.artskin.cn/?p=569</guid>
		<description><![CDATA[最近关于浏览器的最重要的事情就是IE的极光0day漏洞了，这个漏洞导致包括Google在内的多家美国公司受到黑客的攻击，当然也有很多色情网站被黑客利用，从而使用户受到严重的攻击，而IE6用户首当其冲，成为该漏洞的最大受害者。 其实我们天天在想到底哪一天IE6才会真正死去，但是从2001年发布以来，IE6一直统治着国内的浏览器市场，直到现在还占据着国内50%以上的浏览器市场份额。 但是我想，无论你是普通用户还是网站开发人员或者是国内的浏览器开发者，我们都应该采取一些措施，共同促进IE6的灭亡。 如果你是IE6的忠实用户，请尽快升级你的IE6 给你一个升级IE6的理由？好吧： 你和你的公司正在受到安全威胁。这个没有更好的理由来反驳了吧？就连国际知名的大公司如Google、yahoo等都因为使用IE6而受到严重攻击，还有哪家公司的IE6不会受到攻击呢？ 世界上各国政府都在建议大家升级浏览器。在IE6的0day漏洞被曝光之后，德国、法国和澳大利亚等国政府纷纷号召国民放弃使用IE6； 就连微软自己都建议你放弃IE6。微软安全研究与预防博客发文称，IE6受0day漏洞影响最为严重，IE8基本不受该漏洞影响。事实上，微软也不止一次号召用户升级浏览器。 这不是IE6的最后一个严重安全漏洞。IE6从发布到现在不知道出现过多少严重的安全漏洞，而这次远不是终结，它还有至少144个漏洞！ 微软在2014年之后将不再对IE6提供支持。2014年很久远吗？或者你相信2012年就是世界末日？ IE6对web标准的支持缺乏。IE6的技术还是10年前的，互联网技术经过10年的发展已经能够发生了巨大的改变，网站前端技术在不断进步，更先进的CSS、HTML和Javascript等技术已经能给用户带来更好的体验——而IE6用户将无法体验这些先进的内容。比如，前端观察用到的一些CSS3特性将无法在IE6甚至是IE8中体验到。 国内的一部分企业开始要求员工升级浏览器。比如腾讯公司，已经要求所有员工将IE6升级到IE7。 IE6太过时了，国外网友大部分都不再使用IE6了。统计显示，目前国外用户已经逐渐淘汰IE6了。IE8和Firefox是主流(via 人民网)。 国外各大网站开始明确表示将不再支持IE6。比如 Google 将停止支持IE 6 用户必须至少升至IE 7。 (部分参考自：http://mashable.com/2010/01/18/5-more-reasons-why-ie6-must-die/) 如果这几个理由都不够，那么请看国外统计的坚持使用IE6的原因，当然这里有些调侃的意味，如果你正好是其中一种情况，请不要生气 :) ： 当然在国内，坚持使用IE6的用户可能还是因为另外两个原因： 习惯了IE6的操作方式，不喜欢IE7和其它浏览器的tab式浏览。当然一个人的习惯是最重要的。tab的浏览器方式是谁发明的已经不可考了，不过Opera和Firefox纷纷使用，后来国内的maxthon浏览器也采用了那种方式，然后到06年IE7的时候，也采用了tab的方式。这说明tab是一种很好的浏览方式，高效、方便，不然广大网民早就开始反对这种方式了，而各大浏览器也不会坚持下去了。所以建议你尝试一下新技术，从你的习惯中走出来。 IE6比较快，IE7和IE8太慢了。IE7和IE8的确太慢了，不过新版的Firefox 3.6和Chrome一直是很快的哦。 前端开发人员可以争取放弃兼容IE6 如果你是一名光荣的前端开发人员，希望你能尽可能的做更多的事情来让IE6更快的死去： 以身作则，自己放弃IE6。从前端观察和其它技术网站的访问统计上看，IE6的用户比例竟然还有30%以上，这让我很震惊。作为一名前端开发者，用IE6做自己的主浏览器，那么你做的网站应该也不会在IE7/8以及其它更先进的浏览器中做测试的吧？ 说服你的BOSS或客户，放弃兼容IE6。有必要为了让网站在IE6中和其它浏览器中表现一直而花掉2倍甚至是3倍的时间和精力吗？我认为对不同的浏览器，可以采取适当的区分——让网站在现代浏览器如Firefox 3.5+、Chrome/Safari和Opera中实现最佳的表现，而在IE中实现相对比较差的界面——当然在不影响布局和功能的情况下。 号召你的朋友弃用IE6。号召你身边的朋友使用IE7/8或者Firefox、Chrome等浏览器。另外，很多人都有个人博客，可以在自己的博客上号召IE6用户升级他们的浏览器。你也可以参与到众多的促进IE6升级的在线项目中来，比如 webrebuild.org的IE６升级活动以及效果很不错的IE6 Update中。 浏览器厂商应该负更多的责任 想起的一句话：此地钱多人傻，速来！这当然只是笑话。 不过据说现在中国网民数量已经高达3.6亿！而且这个数字还在不断增长。这显然是一个巨大的市场。 所以最近各大公司纷纷涉足浏览器市场，各自都推出自有品牌的浏览器，在Maxthon、世界之窗、腾讯TT、绿色浏览器等混战多年的情况下又出现搜狐浏览器、新浪浏览器和360浏览器。但是它们无一不是以IE为内核的(maxthon和搜狐浏览器有IE和webkit双内核的版本)，没有自己的内核。所以各位网民，不要以为你用了所谓“安全”浏览器你的电脑就安全了，它的内核IE本身都是不安全的，这些外壳浏览器谈何安全——不过有些浏览器会添加一些可以避免你误操作的功能。 对国内的浏览器市场来说，我认为这种“战国纷争”的局面是很不错的，至少能够普及一点儿“浏览器”知识，提高网民对互联网和互联网安全的认识。 但是我认为国内的浏览器厂商应该负起更多的责任。 你们的浏览器产品确实有很多特色，也有很多很有用或者很酷的功能，比较重视中国人的使用习惯。但是当用户因为IE的漏洞而被攻击的时候，你们会承担责任吗？还是将责任推到微软那里？这似乎有些不公平哦～～ 对IE来说，最安全的、功能最强、稳定性最好的应该就是IE8了，如果你们能够推动用户去升级他们的内核到最新版，肯定能降低你们要为安全承担的风险。另外，减少一个内核支持也会减少你们的开发和维护支出吧。 总结 让IE6退出历史舞台，不是一朝一夕的事情，用户的惰性让他不愿意主动去升级，微软的浏览器升级模式又那么古老（而Firefox的提示升级和Chrome的后台自动升级模式倒省去了不少麻烦）。所以我们只有靠自己的力量来推动IE6的灭亡了。 转自：http://www.qianduan.net/let-ie6-faster-dead.html]]></description>
			<content:encoded><![CDATA[<p>最近关于浏览器的最重要的事情就是IE的极光0day漏洞了，这个漏洞导致包括Google在内的多家美国公司受到黑客的攻击，当然也有很多色情网站被黑客利用，从而使用户受到严重的攻击，而IE6用户首当其冲，成为该漏洞的最大受害者。</p>
<p>其实我们天天在想到底哪一天IE6才会真正死去，<span id="more-569"></span>但是从2001年发布以来，IE6一直统治着国内的浏览器市场，直到现在还占据着国内50%以上的浏览器市场份额。</p>
<p align="center"><a href="http://ripie6.com/"><img src="http://www.artskin.cn/blog/wp-content/uploads/2010/02/ie6rip.jpg" alt="" title="ie6rip" width="300" height="329" class="alignnone size-full wp-image-573" /></a></p>
<p>但是我想，无论你是普通用户还是网站开发人员或者是国内的浏览器开发者，我们都应该采取一些措施，共同促进IE6的灭亡。</p>
<h3>如果你是IE6的忠实用户，请尽快升级你的IE6</h3>
<p>给你一个升级IE6的理由？好吧：</p>
<ol>
<li><strong>你和你的公司正在受到安全威胁。</strong>这个没有更好的理由来反驳了吧？就连国际知名的大公司如Google、yahoo等都因为使用IE6而受到严重攻击，还有哪家公司的IE6不会受到攻击呢？</li>
<li><strong>世界上各国政府都在建议大家升级浏览器。</strong>在IE6的0day漏洞被曝光之后，德国、法国和澳大利亚等国政府纷纷号召国民放弃使用IE6；</li>
<li><strong>就连微软自己都建议你放弃IE6。</strong><a href="http://blogs.technet.com/srd/archive/2010/01/15/assessing-risk-of-ie-0day-vulnerability.aspx" target="_blank">微软安全研究与预防博客</a>发文称，IE6受0day漏洞影响最为严重，IE8基本不受该漏洞影响。事实上，微软也不止一次号召用户升级浏览器。</li>
<li><strong>这不是IE6的最后一个严重安全漏洞。</strong>IE6从发布到现在不知道出现过多少严重的安全漏洞，而这次远不是终结，<a href="http://secunia.com/advisories/product/11/" target="_blank">它还有至少144个漏洞</a>！</li>
<li><strong>微软在2014年之后将不再对IE6提供支持。</strong>2014年很久远吗？或者你相信2012年就是世界末日？</li>
<li><strong>IE6对web标准的支持缺乏。</strong>IE6的技术还是10年前的，互联网技术经过10年的发展已经能够发生了巨大的改变，网站前端技术在不断进步，更先进的CSS、HTML和Javascript等技术已经能给用户带来更好的体验——而IE6用户将无法体验这些先进的内容。比如，前端观察用到的一些CSS3特性将无法在IE6甚至是IE8中体验到。</li>
<li><strong>国内的一部分企业开始要求员工升级浏览器。</strong>比如腾讯公司，已经要求所有员工将IE6升级到IE7。</li>
<li><strong>IE6太过时了，国外网友大部分都不再使用IE6了。</strong>统计显示，目前国外用户已经逐渐淘汰IE6了。<a href="http://it.people.com.cn/GB/42891/42894/10907664.html" target="_blank">IE8和Firefox是主流</a>(via 人民网)。</li>
<li><strong>国外各大网站开始明确表示将不再支持IE6。</strong>比如<a href="http://it.sohu.com/20100202/n269991957.shtml" target="_blank"> Google 将停止支持IE 6 用户必须至少升至IE 7</a>。</li>
</ol>
<p>(部分参考自：<a href="http://mashable.com/2010/01/18/5-more-reasons-why-ie6-must-die/" target="_blank">http://mashable.com/2010/01/18/5-more-reasons-why-ie6-must-die/</a>)</p>
<p>如果这几个理由都不够，那么请看国外统计的坚持使用IE6的原因，当然这里有些调侃的意味，如果你正好是其中一种情况，请不要生气 :) ：</p>
<p align="center"><img src="http://www.artskin.cn/blog/wp-content/uploads/2010/02/ie6reason.jpg" alt="" title="ie6reason" width="500" height="322" class="alignnone size-full wp-image-574" /></p>
<p>当然在国内，坚持使用IE6的用户可能还是因为另外两个原因：</p>
<ol>
<li><strong>习惯了IE6的操作方式，不喜欢IE7和其它浏览器的tab式浏览。</strong>当然一个人的习惯是最重要的。tab的浏览器方式是谁发明的已经不可考了，不过Opera和Firefox纷纷使用，后来国内的maxthon浏览器也采用了那种方式，然后到06年IE7的时候，也采用了tab的方式。这说明tab是一种很好的浏览方式，高效、方便，不然广大网民早就开始反对这种方式了，而各大浏览器也不会坚持下去了。所以建议你尝试一下新技术，从你的习惯中走出来。</li>
<li><strong>IE6比较快，IE7和IE8太慢了。</strong>IE7和IE8的确太慢了，不过新版的Firefox 3.6和Chrome一直是很快的哦。</li>
</ol>
<h3>前端开发人员可以争取放弃兼容IE6</h3>
<p>如果你是一名光荣的前端开发人员，希望你能尽可能的做更多的事情来让IE6更快的死去：</p>
<ol>
<li><strong>以身作则，自己放弃IE6。</strong>从前端观察和其它技术网站的访问统计上看，IE6的用户比例竟然还有30%以上，这让我很震惊。作为一名前端开发者，用IE6做自己的主浏览器，那么你做的网站应该也不会在IE7/8以及其它更先进的浏览器中做测试的吧？</li>
<li><strong>说服你的BOSS或客户，放弃兼容IE6。</strong>有必要为了让网站在IE6中和其它浏览器中表现一直而花掉2倍甚至是3倍的时间和精力吗？我认为对不同的浏览器，可以采取适当的区分——让网站在现代浏览器如Firefox 3.5+、Chrome/Safari和Opera中实现最佳的表现，而在IE中实现相对比较差的界面——当然在不影响布局和功能的情况下。</li>
<li><strong>号召你的朋友弃用IE6。</strong>号召你身边的朋友使用IE7/8或者Firefox、Chrome等浏览器。另外，很多人都有个人博客，可以在自己的博客上号召IE6用户升级他们的浏览器。你也可以参与到众多的促进IE6升级的在线项目中来，比如 <a href="http://www.webrebuild.org/ie6/" target="_blank">webrebuild.org的IE６升级活动</a>以及效果很不错的<a href="http://ie6update.com/" target="_blank">IE6 Update</a>中。</li>
</ol>
<h3>浏览器厂商应该负更多的责任</h3>
<p>想起的一句话：此地钱多人傻，速来！这当然只是笑话。</p>
<p>不过据说现在中国网民数量已经高达3.6亿！而且这个数字还在不断增长。这显然是一个巨大的市场。</p>
<p>所以最近各大公司纷纷涉足浏览器市场，各自都推出自有品牌的浏览器，在Maxthon、世界之窗、腾讯TT、绿色浏览器等混战多年的情况下又出现搜狐浏览器、新浪浏览器和360浏览器。但是它们无一不是以IE为内核的(maxthon和搜狐浏览器有IE和webkit双内核的版本)，没有自己的内核。所以各位网民，不要以为你用了所谓“安全”浏览器你的电脑就安全了，它的内核IE本身都是不安全的，这些外壳浏览器谈何安全——不过有些浏览器会添加一些可以避免你误操作的功能。</p>
<p>对国内的浏览器市场来说，我认为这种“战国纷争”的局面是很不错的，至少能够普及一点儿“浏览器”知识，提高网民对互联网和互联网安全的认识。</p>
<p>但是我认为国内的浏览器厂商应该负起更多的责任。</p>
<p>你们的浏览器产品确实有很多特色，也有很多很有用或者很酷的功能，比较重视中国人的使用习惯。但是当用户因为IE的漏洞而被攻击的时候，你们会承担责任吗？还是将责任推到微软那里？这似乎有些不公平哦～～</p>
<p>对IE来说，最安全的、功能最强、稳定性最好的应该就是IE8了，如果你们能够推动用户去升级他们的内核到最新版，肯定能降低你们要为安全承担的风险。另外，减少一个内核支持也会减少你们的开发和维护支出吧。</p>
<h3>总结</h3>
<p>让IE6退出历史舞台，不是一朝一夕的事情，用户的惰性让他不愿意主动去升级，微软的浏览器升级模式又那么古老（而Firefox的提示升级和Chrome的后台自动升级模式倒省去了不少麻烦）。所以我们只有靠自己的力量来推动IE6的灭亡了。</p>
<p>转自：http://www.qianduan.net/let-ie6-faster-dead.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.artcss.com/archives/569.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
