<?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>Hiro技术站 &#187; Ajax</title>
	<atom:link href="http://www.ihiro.org/tag/ajax/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ihiro.org</link>
	<description></description>
	<lastBuildDate>Fri, 06 Jan 2012 07:58:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Ajax:近期博客改版的增强Ajax加载说明</title>
		<link>http://www.ihiro.org/the-enhanced-ajax-effect-instructions</link>
		<comments>http://www.ihiro.org/the-enhanced-ajax-effect-instructions#comments</comments>
		<pubDate>Thu, 25 Mar 2010 14:05:21 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[Hack技巧]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=1185</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/ajax-wordpress.jpg" alt="" title="ajax-wordpress" width="100" height="100" class="alignleft size-full wp-image-1189" />
<p>近段时间来访问我博客的博友们不知是否注意到，博客的一些地方添加了一些增强型Ajax加载效果，用以提高访客的交互和快速浏览不同分类、标签下最新的文章列表。而在今天又新增了增强型Ajax提交评论和回复，只要你留言你就会看到具体效果。</p>
<p>花了精力添加这些Ajax效果，无非是为了让各位博友和来访者可以更加方便地阅读我的博客，同时也希望大家可以多多给我意见。每次添加新的功能我都会在左边的蓝条里写出来，大家可以一目了然地看到我最新的修改信息。</p>]]></description>
			<content:encoded><![CDATA[<p>近段时间来访问我博客的博友们不知是否注意到，博客的一些地方添加了一些增强型Ajax加载效果，用以提高访客的交互和快速浏览不同分类、标签下最新的文章列表。而在今天又新增了增强型Ajax提交评论和回复，只要你留言你就会看到具体效果。</p>
<p>下面我对几处增强Ajax效果进行一下具体说明，大家以后访问我博客时也可以适当地使用。之所以说是增强型Ajax效果，是因为我并没有改变原先的代码，而是在原始代码基础上添加了jQuery控制，这样即使jQuery代码没有加载完成时，你也可以访问到相应的页面。</p>
<h3>1.Ajax加载历史文章列表：</h3>
<p>在博客的右边有一个最新文章板块，大家可以看到在标题的右边有上页、下页的链接，点击相应的链接便可Ajax加载上下页的文章列表，每次加载10条。图：<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/ajax-recent.png" alt="" title="ajax-recent" width="285" height="314" class="aligncenter size-full wp-image-1187" /></p>
<h3>2.分类Ajax加载相关最新10条文章记录：</h3>
<p>点击博客左边的每个摘要型Post的分类链接、博客右边的分类目录版块链接或者每篇完整型文章的分类链接。会出现一个loading的shadow层，加载完成后罗列出该分类下的最新文章。图：<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/ajax-category.png" alt="" title="ajax-category" width="413" height="284" class="aligncenter size-full wp-image-1186" /></p>
<h3>3.标签Ajax加载相关最新10条文章记录：</h3>
<p>点击博客左边的每个摘要型Post的标签链接、博客右边的热门标签版块链接或者每篇完整型文章的标签链接。同样会出现一个loading的shadow层，加载完成后罗列出该标签下的最新文章。图：<img src="http://www.ihiro.org/blog/wp-content/uploads/2010/03/ajax-tag.png" alt="" title="ajax-tag" width="414" height="282" class="aligncenter size-full wp-image-1188" /></p>
<h3>4.Ajax提交评论和回复别人的留言：</h3>
<p>在此之前，没此提交评论后，当前页面都要重新加载一次，很是耗时。添加Ajax评论后，速度会更快，也大量减少了请求。我的博客一直只提供2层回复。不喜欢多层次回复，看着很难受！具体Ajax评论效果大家只需留言即可看到。</p>
<p>花了精力添加这些Ajax效果，无非是为了让各位博友和来访者可以更加方便地阅读我的博客，同时也希望大家可以多多给我意见。每次添加新的功能我都会在左边的蓝条里写出来，大家可以一目了然地看到我最新的修改信息。</p>
<p>希望我的努力可以让你多多回访，多多支持！！</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2009年09月23日 -- <a href="http://www.ihiro.org/ajax-editing-in-placing" title="Ajax:当前页面更改内容，前端实现">Ajax:当前页面更改内容，前端实现</a> (14)</li><li>2010年10月21日 -- <a href="http://www.ihiro.org/jquery-plugin-recommended-maphighlight" title="jQuery:热区高亮maphighlight插件推荐">jQuery:热区高亮maphighlight插件推荐</a> (23)</li><li>2010年09月20日 -- <a href="http://www.ihiro.org/jquery-format-extend" title="jQuery:数字、字符串格式化扩展">jQuery:数字、字符串格式化扩展</a> (31)</li><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2010年08月12日 -- <a href="http://www.ihiro.org/sizzle-custom-selector" title="Sizzle:开源JS选择器，如何自定义选择器">Sizzle:开源JS选择器，如何自定义选择器</a> (31)</li><li>2010年06月30日 -- <a href="http://www.ihiro.org/firebug-console-panel-function" title="Firebug:Javascript测试利器，Console面板函数详解">Firebug:Javascript测试利器，Console面板函数详解</a> (4)</li><li>2010年06月3日 -- <a href="http://www.ihiro.org/wordpress-3-new-features" title="Wordpress:3.0版本特性，将改变你的内容管理方式">Wordpress:3.0版本特性，将改变你的内容管理方式</a> (12)</li><li>2010年03月15日 -- <a href="http://www.ihiro.org/uncovering-jquerys-hidden-features" title="jQuery:揭露jQuery的隐藏功能">jQuery:揭露jQuery的隐藏功能</a> (5)</li><li>2010年02月26日 -- <a href="http://www.ihiro.org/a-rich-picture-effect-flash" title="jQuery:丰富效果的Flash图片播放（JS重写版）">jQuery:丰富效果的Flash图片播放（JS重写版）</a> (18)</li><li>2010年02月24日 -- <a href="http://www.ihiro.org/javascript-news-flash-header-tips" title="Javascript:新消息闪烁标题提示代码分享">Javascript:新消息闪烁标题提示代码分享</a> (7)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/the-enhanced-ajax-effect-instructions/feed</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
		<item>
		<title>Ajax:当前页面更改内容，前端实现</title>
		<link>http://www.ihiro.org/ajax-editing-in-placing</link>
		<comments>http://www.ihiro.org/ajax-editing-in-placing#comments</comments>
		<pubDate>Wed, 23 Sep 2009 04:26:22 +0000</pubDate>
		<dc:creator>Hiro</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[案例分享]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[前端工程]]></category>

		<guid isPermaLink="false">http://www.ihiro.org/?p=677</guid>
		<description><![CDATA[<img src="http://www.ihiro.org/blog/wp-content/uploads/2009/09/Ajax-Editing-150x150.jpg" alt="Ajax-Editing" title="Ajax-Editing" width="100" height="100" class="alignleft wp-image-682" />
<p>相信大家有用过Google Doc或Flickr，或者一些SNS社区的图片添加描述信息的效果，他们是在点击了一段文字后出现一个输入框，在输入框内输入你要填写的内容，点击“确认”或者“发表”即可立即显示出来。</p>
<p>今天做的这个效果呢，就是其中的截取版本。为什么这么说呢，因为我的效果只实现了前端的更改后立即发布的效果，而没有实际的与服务器端交互，也没有将输入的内容添加到数据库中，主要是为大家介绍一下实现原理。</p>
<p class="color-red">注意：源代码中没有jQuery库文件，请下载查看代码的朋友根据源代码路径自行添加。</p>]]></description>
			<content:encoded><![CDATA[<p>相信大家有用过Google Doc或Flickr，或者一些SNS社区的图片添加描述信息的效果，他们是在点击了一段文字后出现一个输入框，在输入框内输入你要填写的内容，点击“确认”或者“发表”即可立即显示出来。</p>
<p>今天做的这个效果呢，就是其中的截取版本。为什么这么说呢，因为我的效果只实现了前端的更改后立即发布的效果，而没有实际的与服务器端交互，也没有将输入的内容添加到数据库中，主要是为大家介绍一下实现原理。</p>
<p class="demo-down-bar"><a href="http://www.ihiro.org/cases/AjaxEditing/AjaxEditing.rar" class="download">download</a><a href="http://www.ihiro.org/cases/AjaxEditing/" class="demo">demo</a></p>
<h3>1.HTML代码：</h3>
<p>
<div class="wp_codebox"><table><tr id="p6771"><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
</pre></td><td class="code" id="p677code1"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;container&quot;&gt;
  &lt;h1&gt;Ajax Editing&lt;/h1&gt;
  &lt;p&gt;鼠标移动到列表上，双击即可以进行编辑！&lt;/p&gt;
  &lt;div class=&quot;block&quot;&gt;
    &lt;h2&gt;一、电影列表&lt;/h2&gt;
    &lt;ul class=&quot;editable&quot;&gt;
      &lt;li&gt;《建国大业》，&lt;span class=&quot;color_red&quot;&gt;更新中...&lt;/span&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/film-eternal-beloved&quot;&gt;《爱有来生》&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/movie-coco-chanel&quot;&gt;《COCO Chanel》&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/one-night-in-supermarket&quot;&gt;《夜店》&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/the-legend-of-1900&quot;&gt;《海上钢琴师–1900的传说》&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;http://www.ihiro.org/film-xinsushijian-feedback&quot;&gt;《新宿事件》&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  &lt;div class=&quot;block&quot;&gt;
    &lt;h2&gt;二、书籍列表&lt;/h2&gt;
    &lt;ul class=&quot;editable&quot;&gt;
      &lt;li&gt;《精通Javascript》&lt;/li&gt;
      &lt;li&gt;《jQuery基础教程》&lt;/li&gt;
      &lt;li&gt;《Flex入门到精通》&lt;/li&gt;
      &lt;li&gt;《PHP与MySQL Web开发》&lt;/li&gt;
      &lt;li&gt;《Google，你可以做什么》&lt;/li&gt;
      &lt;li&gt;《不抱怨的世界》&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

</p>
<h3></h3>
<p>
<div class="wp_codebox"><table><tr id="p6772"><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
</pre></td><td class="code" id="p677code2"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span>/<span style="color: #933;">20px</span> Georgia<span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Times New Roman&quot;</span><span style="color: #00AA00;">,</span> Times<span style="color: #00AA00;">,</span> <span style="color: #993333;">serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#404040</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
h2 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">24px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.color_red</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#F00</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#container</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">1%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/* 标题样式 */</span>
	<span style="color: #cc00cc;">#container</span> h1 <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span><span style="color: #993333;">center</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">32px</span> <span style="color: #ff0000;">&quot;Lucida Sans Unicode&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #ff0000;">&quot;Lucida Grande&quot;</span><span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	.<span style="color: #993333;">block</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">180px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">30px</span> <span style="color: #933;">20px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/* 列表li的样式 */</span>
	ul<span style="color: #6666ff;">.editable</span> li <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/* 高亮当前编辑的列表li */</span>
	<span style="color: #6666ff;">.hover</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#E8F3FF</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #808080; font-style: italic;">/* 高亮当前的input输入框 */</span>
	<span style="color: #6666ff;">.editInput</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">160px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#E8F3FF</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
&nbsp;
	<span style="color: #808080; font-style: italic;">/* save和cancel按钮的效果，鼠标移动到上面的效果 */</span>
	<span style="color: #6666ff;">.btnSave</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.btnCancel</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#09F</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#36F</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
	<span style="color: #6666ff;">.btnSave</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.btnCancel</span><span style="color: #3333ff;">:hover  </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#36F</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#39F</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

</p>
<h3>3. jQuery代码：</h3>
<p>
<div class="wp_codebox"><table><tr id="p6773"><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="p677code3"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> oldText<span style="color: #339933;">,</span> newText<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//鼠标移动到列表li上后，添加一个高亮的背景</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.editable li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">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: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hover'</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: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hover'</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: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'dblclick'</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>
&nbsp;
		<span style="color: #006600; font-style: italic;">//获得列表li中原先的html代码</span>
		oldText <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&quot;/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&amp;quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//将原先的html代码放在一个input中，并追加save和cancel按钮后插入到列表li中</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;input type=&quot;text&quot; class=&quot;editInput&quot; value=&quot;'</span> <span style="color: #339933;">+</span> oldText <span style="color: #339933;">+</span><span style="color: #3366CC;">'&quot; /&gt;&lt;a href=&quot;#&quot; class=&quot;btnSave&quot;&gt;save&lt;/a&gt;&lt;a href=&quot;#&quot; class=&quot;btnCancel&quot;&gt;cancel&lt;/a&gt;'</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: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'target'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'_blank'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	<span style="color: #006600; font-style: italic;">//链接在新窗口中打开</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">//点击save按钮，将新的值插入在列表li中</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.btnSave'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</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>
		newText <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&quot;/g</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&amp;quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>newText<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//设置超链接a的跳转为否</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>
&nbsp;
	<span style="color: #006600; font-style: italic;">//若点击cancel按钮，则将最初的html代码插入在列表li中</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.btnCancel'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">live</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</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: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>oldText<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//设置超链接a的跳转为否</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>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>双击列表li后，将原先列表li中的html源码保存在oldText变量中，并且在列表li标签内插入一个input输入框和两个链接作为按钮save和cancel之用；<br />
点击save按钮后，将input中的新的html源码保存在newText变量中，重新插入到列表li中，从而覆盖了列表里中的input源码；<br />
点击cancel按钮，浙江原先的html代码oldText重新插入到列表li中，覆盖掉因双击插入的input输入框和两个链接按钮。
</p>
<p class="color-red">注意：源代码中没有jQuery库文件，请下载查看代码的朋友根据源代码路径自行添加。</p>
<h2  class="related_post_title">你也许会喜欢阅读这些：</h2><ul class="related_post"><li>2009年11月26日 -- <a href="http://www.ihiro.org/jquery-enhanced-marquee-bulletin-board" title="jQuery:增强型走马灯公告栏，可以抛弃marquee标签了">jQuery:增强型走马灯公告栏，可以抛弃marquee标签了</a> (20)</li><li>2010年11月25日 -- <a href="http://www.ihiro.org/css-position-hack" title="CSS:position属性定位总结">CSS:position属性定位总结</a> (27)</li><li>2010年09月2日 -- <a href="http://www.ihiro.org/example-selectbox-simulation" title="示例:Selectbox模拟实现效果">示例:Selectbox模拟实现效果</a> (22)</li><li>2010年03月25日 -- <a href="http://www.ihiro.org/the-enhanced-ajax-effect-instructions" title="Ajax:近期博客改版的增强Ajax加载说明">Ajax:近期博客改版的增强Ajax加载说明</a> (43)</li><li>2010年03月15日 -- <a href="http://www.ihiro.org/uncovering-jquerys-hidden-features" title="jQuery:揭露jQuery的隐藏功能">jQuery:揭露jQuery的隐藏功能</a> (5)</li><li>2010年03月8日 -- <a href="http://www.ihiro.org/css3-basic" title="CSS:CSS3基础（附图）">CSS:CSS3基础（附图）</a> (12)</li><li>2010年01月22日 -- <a href="http://www.ihiro.org/jquery-1-4-released-the-15-new-features-you-should-know-2" title="jQuery:1.4新版本中你应该知道的15个新特性(二)">jQuery:1.4新版本中你应该知道的15个新特性(二)</a> (7)</li><li>2010年01月20日 -- <a href="http://www.ihiro.org/jquery-1-4-released-the-15-new-features-you-should-know-1" title="jQuery:1.4新版本中你应该知道的15个新特性(一)">jQuery:1.4新版本中你应该知道的15个新特性(一)</a> (6)</li><li>2009年12月16日 -- <a href="http://www.ihiro.org/jquery-once-through-the-event-delegate-to-bind-a-variety-of-time-in-order-to-reduce-the-event-of-redundancy" title="jQuery:通过事件委派一次绑定多种事件，以减少事件冗余">jQuery:通过事件委派一次绑定多种事件，以减少事件冗余</a> (7)</li><li>2009年12月1日 -- <a href="http://www.ihiro.org/how-to-custom-alias-in-plugins-and-page-code" title="jQuery:如何在页面和插件代码中自定义别名">jQuery:如何在页面和插件代码中自定义别名</a> (5)</li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.ihiro.org/ajax-editing-in-placing/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
