<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>走走停停看看 &#187; 插件</title>
	<atom:link href="http://shawphy.com/tag/%e6%8f%92%e4%bb%b6/feed" rel="self" type="application/rss+xml" />
	<link>http://shawphy.com</link>
	<description>关注HTML,CSS,JavaScript,jQuery等前端开发</description>
	<lastBuildDate>Mon, 12 Jul 2010 15:45:21 +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>json2select</title>
		<link>http://shawphy.com/2008/12/json2select.html</link>
		<comments>http://shawphy.com/2008/12/json2select.html#comments</comments>
		<pubDate>Sat, 20 Dec 2008 05:57:17 +0000</pubDate>
		<dc:creator>Shawphy</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://shawphy.com/2008/12/json2select.html</guid>
		<description><![CDATA[这是我之前为了ThinkSNS写的一个小工具。通过json生成无限联动的select。至少要求jQuery 1.2.3 以上，因为我用了data方法。 查看DEMO 源文件 min版 //构建如下json，t为列表框的text,v为列表框的value，s表示子一级对象 var&#160;json=[ &#160; &#160; { &#160; &#160; &#160; &#160; t:&#34;欧洲某地&#34;, &#160; &#160; &#160; &#160; v:&#34;欧洲&#34; &#160; &#160; }, &#160; &#160; { &#160; &#160; &#160; &#160; t:&#34;中国某地&#34;, &#160; &#160; &#160; &#160; v:&#34;中国&#34;, &#160; &#160; &#160; &#8230; <a href="http://shawphy.com/2008/12/json2select.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>这是我之前为了<a href="http://www.thinksns.com">ThinkSNS</a>写的一个小工具。通过json生成无限联动的select。至少要求jQuery 1.2.3 以上，因为我用了data方法。<br />
<a href="http://shawphy.googlecode.com/svn/javascript/json2select/json2select.html">查看DEMO</a> <a href="http://shawphy.googlecode.com/svn/javascript/json2select/json2select.js">源文件</a> <a href="http://shawphy.googlecode.com/svn/javascript/json2select/json2select.min.js">min版</a></p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: #ffa500;">//构建如下json，t为列表框的text,v为列表框的value，s表示子一级对象</span></li>
<li><span style="color: Green;">var</span><span style="color: Gray;">&nbsp;</span><span style="color: Blue;">json</span><span style="color: Gray;">=</span><span style="color: Olive;">[</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">t</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">欧洲某地</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">v</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">欧洲</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">t</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">中国某地</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">v</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">中国</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">s</span><span style="color: Gray;">:</span><span style="color: Olive;">[</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">t</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">上海</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">v</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">上海</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">t</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">云南某地</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">v</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">云南</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">s</span><span style="color: Gray;">:</span><span style="color: Olive;">[</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">t</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">大理</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">v</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">大理</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">]</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">]</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">t</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">日本某地</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">v</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">日本</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">s</span><span style="color: Gray;">:</span><span style="color: Olive;">[</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">t</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">东京</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">v</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">东京</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">t</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">北海道</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">v</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">北海道</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">s</span><span style="color: Gray;">:</span><span style="color: Olive;">[</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">t</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">北海道的某个地方</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Blue;">v</span><span style="color: Gray;">:</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">北海道的某个地方</span><span style="color: #8b0000;">&quot;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">]</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Olive;">]</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Olive;">]</span><span style="color: Gray;">;</span></li>
<li><span style="color: #ffa500;">//调用即可</span></li>
<li><span style="color: Gray;">$</span><span style="color: Olive;">(</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">#selectt</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">)</span><span style="color: Gray;">.</span><span style="color: Blue;">json2select</span><span style="color: Olive;">(</span><span style="color: Blue;">json</span><span style="color: Gray;">,</span><span style="color: Olive;">[</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">中国</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">云南</span><span style="color: #8b0000;">&quot;</span><span style="color: Gray;">,</span><span style="color: #8b0000;">&quot;</span><span style="color: Red;">大理</span><span style="color: #8b0000;">&quot;</span><span style="color: Olive;">])</span><span style="color: Gray;">;</span></li></ol></div>
<p>另外，如果用1.2.1的也想用的话，可以手动提取1.2.6里的data方法，或者简单用下面的模拟一下即可</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline"><span style="color: Olive;">(</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Gray;">$</span><span style="color: Olive;">)</span><span style="color: Gray;"> </span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; $.</span><span style="color: Blue;">fn</span><span style="color: Gray;">.</span><span style="color: Blue;">data</span><span style="color: Gray;">=</span><span style="color: Green;">function</span><span style="color: Olive;">(</span><span style="color: Blue;">key</span><span style="color: Gray;">,</span><span style="color: Blue;">value</span><span style="color: Olive;">)</span><span style="color: Gray;">&nbsp;</span><span style="color: Olive;">{</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: Green;">return</span><span style="color: Gray;"> $.</span><span style="color: Blue;">data</span><span style="color: Olive;">(</span><span style="color: Green;">this</span><span style="color: Olive;">[</span><span style="color: Maroon;">0</span><span style="color: Olive;">]</span><span style="color: Gray;">,</span><span style="color: Blue;">key</span><span style="color: Gray;">,</span><span style="color: Blue;">value</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li>
<li><span style="color: Gray;">&nbsp; &nbsp; </span><span style="color: Olive;">}</span></li>
<li><span style="color: Olive;">})(</span><span style="color: Blue;">jQuery</span><span style="color: Olive;">)</span><span style="color: Gray;">;</span></li></ol></div>
<p><strong>update:</strong><br />
附： <a href="http://shawphy.com/2009/07/json2select-data-of-city.html">全国城市数据</a><br />
并且更新到了 1.0.1版。以前下载的同学可以重新下载一份。</p>
]]></content:encoded>
			<wfw:commentRss>http://shawphy.com/2008/12/json2select.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
