﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-liuyf8688-文章分类-Javascript</title><link>http://www.blogjava.net/liuyf8688/category/43980.html</link><description /><language>zh-cn</language><lastBuildDate>Thu, 28 Jan 2016 15:35:03 GMT</lastBuildDate><pubDate>Thu, 28 Jan 2016 15:35:03 GMT</pubDate><ttl>60</ttl><item><title>JS中最简单的HashMap实现</title><link>http://www.blogjava.net/liuyf8688/articles/429236.html</link><dc:creator>liuyf8688</dc:creator><author>liuyf8688</author><pubDate>Wed, 27 Jan 2016 11:00:00 GMT</pubDate><guid>http://www.blogjava.net/liuyf8688/articles/429236.html</guid><wfw:comment>http://www.blogjava.net/liuyf8688/comments/429236.html</wfw:comment><comments>http://www.blogjava.net/liuyf8688/articles/429236.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuyf8688/comments/commentRss/429236.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuyf8688/services/trackbacks/429236.html</trackback:ping><description><![CDATA[<div>&lt;script&gt;</div><div><span style="white-space:pre">	</span>var hashMap = { 407624 : "12--",</div><div><span style="white-space:pre">					</span>407625 : "22--",</div><div><span style="white-space:pre">					</span>407625 : "22--",</div><div><span style="white-space:pre">					</span>407626 : "32--",</div><div><span style="white-space:pre">					</span>407627 : "42--",</div><div><span style="white-space:pre">					</span>407628 : "52--",</div><div><span style="white-space:pre">					</span>407627 : "42--",</div><div><span style="white-space:pre">					</span>407627 : "42--",</div><div><span style="white-space:pre">					</span>407627 : "42--",</div><div><span style="white-space:pre">					</span>407627 : "42--",</div><div><span style="white-space:pre">					</span>407627 : "42--",</div><div><span style="white-space:pre">					</span>407627 : "42--",</div><div><span style="white-space:pre">					</span>407627 : "42--",</div><div><span style="white-space:pre">					</span>407627 : "42--",</div><div><span style="white-space:pre">					</span>407627 : "42--",</div><div><span style="white-space:pre">					</span>407627 : "42--"</div><div><span style="white-space:pre">				</span>};</div><div><span style="white-space:pre">	</span>// alert(hashmap[407624]);</div><div><span style="white-space:pre">	</span>// alert(hashmap[407625]);</div><div><span style="white-space:pre">	</span></div><div><span style="white-space:pre">	</span>for (var key in hashmap) {</div><div><span style="white-space:pre">		</span>console.log(hashmap[key]);</div><div><span style="white-space:pre">	</span>}</div><div>&lt;/script&gt;<br /></div><img src ="http://www.blogjava.net/liuyf8688/aggbug/429236.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuyf8688/" target="_blank">liuyf8688</a> 2016-01-27 19:00 <a href="http://www.blogjava.net/liuyf8688/articles/429236.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Json String解析</title><link>http://www.blogjava.net/liuyf8688/articles/426563.html</link><dc:creator>liuyf8688</dc:creator><author>liuyf8688</author><pubDate>Mon, 03 Aug 2015 10:33:00 GMT</pubDate><guid>http://www.blogjava.net/liuyf8688/articles/426563.html</guid><wfw:comment>http://www.blogjava.net/liuyf8688/comments/426563.html</wfw:comment><comments>http://www.blogjava.net/liuyf8688/articles/426563.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuyf8688/comments/commentRss/426563.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuyf8688/services/trackbacks/426563.html</trackback:ping><description><![CDATA[背景<br /><br />1.后台发布API，返回结果为JSON。<br />2.前端采用AJAX异步请求。<br /><br />通常我们会碰到后台API返回单个返回值，类型为string的情况。<br />但是我们查看浏览器控制台或通过alter直接打印结果时，通常该值是被包裹在双引号中。<br />例如，"http://www.baidu.com"<br /><br />＝＝＝＝＝＝＝＝＝＝＝＝＝割割割割割割割割===================<br /><br />我们很困惑，<br />前端说：后端应该返回string，不带双引号。<br />后端说：我们返回的是标准JSON格式，不能去掉双引号。<br />前端说：标准JSON格式为什么不带大括号（{}）。<br /><br />如果我们细心的去查询JSON官方站点(<a href="http://json.org" title="http://json.org">http://json.org</a>)的话，我们会发现JSON拥有一个单独的类型为String。<br />定义如下：<br /><br />A&nbsp;<em>string</em>&nbsp;is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes. A character is represented as a single character string. A string is very much like a C or Java string<br /><br />String是由0个或多个Unicode字符组成的序列，被包裹在双引号中。可以使用斜杠（\）来逃逸关键字或特殊字符。字符表示单个的字符串。<br />字符串与C或JAVA中的字符串非常相似。<br /><br />现在我们明白了，原来这是一种标准的JSON格式。<br />那么我们怎么解析他呢。<br /><br />其实非常简单，我们把他当作普通的JSON来解析就可以了。<br /><div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />-->&lt;script&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">var</span>&nbsp;jsontext&nbsp;=&nbsp;'"http://www.baidu.com"';<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">&nbsp;变身</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">var</span>&nbsp;url&nbsp;=&nbsp;JSON.parse(jsontext);<br />&nbsp;&nbsp;&nbsp;&nbsp;alert(url);<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">&nbsp;再变身</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">var</span>&nbsp;json&nbsp;=&nbsp;JSON.stringify(url);<br />&nbsp;&nbsp;&nbsp;&nbsp;alert(json);&nbsp;&nbsp;&nbsp;&nbsp;<br />&lt;/script&gt;</div><img src ="http://www.blogjava.net/liuyf8688/aggbug/426563.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuyf8688/" target="_blank">liuyf8688</a> 2015-08-03 18:33 <a href="http://www.blogjava.net/liuyf8688/articles/426563.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jQuery插件开发注意事项</title><link>http://www.blogjava.net/liuyf8688/articles/354772.html</link><dc:creator>liuyf8688</dc:creator><author>liuyf8688</author><pubDate>Thu, 21 Jul 2011 04:33:00 GMT</pubDate><guid>http://www.blogjava.net/liuyf8688/articles/354772.html</guid><wfw:comment>http://www.blogjava.net/liuyf8688/comments/354772.html</wfw:comment><comments>http://www.blogjava.net/liuyf8688/articles/354772.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuyf8688/comments/commentRss/354772.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuyf8688/services/trackbacks/354772.html</trackback:ping><description><![CDATA[<span class="Apple-style-span" style="font-family: 'Trebuchet MS', Verdana, Helvetica, Arial, sans-serif; font-size: 13px; line-height: 19px; "><ul style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.3em; margin-right: 0px; margin-bottom: 0px; margin-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: transparent; list-style-type: square; list-style-position: initial; list-style-image: url(http://docs.jquery.com/skins/monobook/bullet.gif); line-height: 1.5em; background-position: initial initial; background-repeat: initial initial; "><li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.5em !important; margin-right: 0px !important; margin-bottom: 0.5em !important; margin-left: 0px !important; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; line-height: 1.5 !important; font-weight: normal; background-position: initial initial !important; background-repeat: initial initial !important; ">Always wrap your plugin in&nbsp;<code style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px !important; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f9f9f9; background-position: initial initial; background-repeat: initial initial; ">(function( $ ){ // plugin goes here })( jQuery );</code></li><li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.5em !important; margin-right: 0px !important; margin-bottom: 0.5em !important; margin-left: 0px !important; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; line-height: 1.5 !important; font-weight: normal; background-position: initial initial !important; background-repeat: initial initial !important; ">Don't redundantly wrap the&nbsp;<code style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px !important; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f9f9f9; background-position: initial initial; background-repeat: initial initial; ">this</code>&nbsp;keyword in the immediate scope of your plugin's function</li><li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.5em !important; margin-right: 0px !important; margin-bottom: 0.5em !important; margin-left: 0px !important; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; line-height: 1.5 !important; font-weight: normal; background-position: initial initial !important; background-repeat: initial initial !important; ">Unless you're returning an intrinsic value from your plugin, always have your plugin's function return the&nbsp;<code style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px !important; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f9f9f9; background-position: initial initial; background-repeat: initial initial; ">this</code>&nbsp;keyword to maintain chainability.</li><li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.5em !important; margin-right: 0px !important; margin-bottom: 0.5em !important; margin-left: 0px !important; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; line-height: 1.5 !important; font-weight: normal; background-position: initial initial !important; background-repeat: initial initial !important; ">Rather than requiring a lengthy amount of arguments, pass your plugin settings in an object literal that can be extended over the plugin's defaults.</li><li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.5em !important; margin-right: 0px !important; margin-bottom: 0.5em !important; margin-left: 0px !important; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; line-height: 1.5 !important; font-weight: normal; background-position: initial initial !important; background-repeat: initial initial !important; ">Don't clutter the&nbsp;<code style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px !important; vertical-align: baseline; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f9f9f9; background-position: initial initial; background-repeat: initial initial; ">jQuery.fn</code>&nbsp;object with more than one namespace per plugin.</li><li style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0.5em !important; margin-right: 0px !important; margin-bottom: 0.5em !important; margin-left: 0px !important; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-size: 13px; vertical-align: baseline; background-image: none !important; background-attachment: initial !important; background-origin: initial !important; background-clip: initial !important; background-color: initial !important; line-height: 1.5 !important; font-weight: normal; background-position: initial initial !important; background-repeat: initial initial !important; ">Always namespace your methods, events and data.</li></ul></span><img src ="http://www.blogjava.net/liuyf8688/aggbug/354772.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuyf8688/" target="_blank">liuyf8688</a> 2011-07-21 12:33 <a href="http://www.blogjava.net/liuyf8688/articles/354772.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>验证输入的文本长度，区分全角和半角</title><link>http://www.blogjava.net/liuyf8688/articles/314794.html</link><dc:creator>liuyf8688</dc:creator><author>liuyf8688</author><pubDate>Mon, 08 Mar 2010 03:30:00 GMT</pubDate><guid>http://www.blogjava.net/liuyf8688/articles/314794.html</guid><wfw:comment>http://www.blogjava.net/liuyf8688/comments/314794.html</wfw:comment><comments>http://www.blogjava.net/liuyf8688/articles/314794.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuyf8688/comments/commentRss/314794.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuyf8688/services/trackbacks/314794.html</trackback:ping><description><![CDATA[<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #008080; ">&#160;1</span>&#160;<span style="color: #000000; ">&lt;</span><span style="color: #000000; ">script&#160;type</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">text/javascript</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; "><br />
</span><span style="color: #008080; ">&#160;2</span>&#160;<span style="color: #008000; ">/*</span><span style="color: #008000; ">*<br />
</span><span style="color: #008080; ">&#160;3</span>&#160;<span style="color: #008000; ">*&#160;字符串求长度(全角)<br />
</span><span style="color: #008080; ">&#160;4</span>&#160;<span style="color: #008000; ">*/</span><span style="color: #000000; "><br />
</span><span style="color: #008080; ">&#160;5</span>&#160;<span style="color: #000000; ">String.prototype._getLength&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;</span><span style="color: #0000FF; ">function</span><span style="color: #000000; ">()&#160;{<br />
</span><span style="color: #008080; ">&#160;6</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;</span><span style="color: #0000FF; ">var</span><span style="color: #000000; ">&#160;str&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">;<br />
</span><span style="color: #008080; ">&#160;7</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;</span><span style="color: #0000FF; ">var</span><span style="color: #000000; ">&#160;len&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;str.length;<br />
</span><span style="color: #008080; ">&#160;8</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;</span><span style="color: #0000FF; ">var</span><span style="color: #000000; ">&#160;reLen&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">;<br />
</span><span style="color: #008080; ">&#160;9</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;</span><span style="color: #0000FF; ">for</span><span style="color: #000000; ">&#160;(</span><span style="color: #0000FF; ">var</span><span style="color: #000000; ">&#160;i&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">0</span><span style="color: #000000; ">;&#160;i&#160;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">&#160;len;&#160;i</span><span style="color: #000000; ">++</span><span style="color: #000000; ">)&#160;{&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
</span><span style="color: #008080; ">10</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000FF; ">if</span><span style="color: #000000; ">&#160;(str.charCodeAt(i)&#160;</span><span style="color: #000000; ">&lt;</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">27</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">||</span><span style="color: #000000; ">&#160;str.charCodeAt(i)&#160;</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">126</span><span style="color: #000000; ">)&#160;{<br />
</span><span style="color: #008080; ">11</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #008000; ">//</span><span style="color: #008000; ">&#160;全角&#160;&#160;&#160;</span><span style="color: #008000; "><br />
</span><span style="color: #008080; ">12</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;reLen&#160;</span><span style="color: #000000; ">+=</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">2</span><span style="color: #000000; ">;<br />
</span><span style="color: #008080; ">13</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}&#160;</span><span style="color: #0000FF; ">else</span><span style="color: #000000; ">&#160;{<br />
</span><span style="color: #008080; ">14</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;reLen</span><span style="color: #000000; ">++</span><span style="color: #000000; ">;<br />
</span><span style="color: #008080; ">15</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}<br />
</span><span style="color: #008080; ">16</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;}<br />
</span><span style="color: #008080; ">17</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&#160;reLen;&#160;&#160;&#160;<br />
</span><span style="color: #008080; ">18</span>&#160;<span style="color: #000000; ">}<br />
</span><span style="color: #008080; ">19</span>&#160;<span style="color: #0000FF; ">function</span><span style="color: #000000; ">&#160;test(){<br />
</span><span style="color: #008080; ">20</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;alert(document.getElementById(</span><span style="color: #000000; ">"</span><span style="color: #000000; ">inputDemo</span><span style="color: #000000; ">"</span><span style="color: #000000; ">).value._getLength());<br />
</span><span style="color: #008080; ">21</span>&#160;<span style="color: #000000; ">}<br />
</span><span style="color: #008080; ">22</span>&#160;<span style="color: #000000; ">&lt;/</span><span style="color: #000000; ">script</span><span style="color: #000000; ">&gt;</span><span style="color: #000000; "><br />
</span><span style="color: #008080; ">23</span>&#160;<span style="color: #000000; "><br />
</span><span style="color: #008080; ">24</span>&#160;<span style="color: #000000; ">&lt;</span><span style="color: #000000; ">input&#160;type</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">text</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;id</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">inputDemo</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;</span><span style="color: #000000; ">/&gt;</span><span style="color: #000000; "><br />
</span><span style="color: #008080; ">25</span>&#160;<span style="color: #000000; ">&lt;</span><span style="color: #000000; ">input&#160;type</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">button</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;value</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">click&#160;me!</span><span style="color: #000000; ">"</span><span style="color: #000000; ">&#160;onclick</span><span style="color: #000000; ">=</span><span style="color: #000000; ">"</span><span style="color: #000000; ">test()</span><span style="color: #000000; ">"</span><span style="color: #000000; ">/&gt;</span></div>
<img src ="http://www.blogjava.net/liuyf8688/aggbug/314794.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuyf8688/" target="_blank">liuyf8688</a> 2010-03-08 11:30 <a href="http://www.blogjava.net/liuyf8688/articles/314794.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>js中实现trim方法</title><link>http://www.blogjava.net/liuyf8688/articles/313446.html</link><dc:creator>liuyf8688</dc:creator><author>liuyf8688</author><pubDate>Sat, 20 Feb 2010 05:47:00 GMT</pubDate><guid>http://www.blogjava.net/liuyf8688/articles/313446.html</guid><wfw:comment>http://www.blogjava.net/liuyf8688/comments/313446.html</wfw:comment><comments>http://www.blogjava.net/liuyf8688/articles/313446.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/liuyf8688/comments/commentRss/313446.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/liuyf8688/services/trackbacks/313446.html</trackback:ping><description><![CDATA[<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: #008080; ">&#160;1</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;String.prototype.Trim&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;function(){<br />
</span><span style="color: #008080; ">&#160;2</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&#160;</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">.replace(</span><span style="color: #000000; ">/</span><span style="color: #000000; ">(</span><span style="color: #000000; ">^</span><span style="color: #000000; ">\s</span><span style="color: #000000; ">*</span><span style="color: #000000; ">)</span><span style="color: #000000; ">|</span><span style="color: #000000; ">(\s</span><span style="color: #000000; ">*</span><span style="color: #000000; ">$)</span><span style="color: #000000; ">/</span><span style="color: #000000; ">g,&#160;</span><span style="color: #000000; ">""</span><span style="color: #000000; ">);<br />
</span><span style="color: #008080; ">&#160;3</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;}<br />
</span><span style="color: #008080; ">&#160;4</span>&#160;<span style="color: #000000; "><br />
</span><span style="color: #008080; ">&#160;5</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;String.prototype.LTrim&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;function(){<br />
</span><span style="color: #008080; ">&#160;6</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&#160;</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">.replace(</span><span style="color: #000000; ">/</span><span style="color: #000000; ">(</span><span style="color: #000000; ">^</span><span style="color: #000000; ">\s</span><span style="color: #000000; ">*</span><span style="color: #000000; ">)</span><span style="color: #000000; ">/</span><span style="color: #000000; ">g,&#160;</span><span style="color: #000000; ">""</span><span style="color: #000000; ">);<br />
</span><span style="color: #008080; ">&#160;7</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;}<br />
</span><span style="color: #008080; ">&#160;8</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;String.prototype.RTrim&#160;</span><span style="color: #000000; ">=</span><span style="color: #000000; ">&#160;function(){<br />
</span><span style="color: #008080; ">&#160;9</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000FF; ">return</span><span style="color: #000000; ">&#160;</span><span style="color: #0000FF; ">this</span><span style="color: #000000; ">.replace(</span><span style="color: #000000; ">/</span><span style="color: #000000; ">(\s</span><span style="color: #000000; ">*</span><span style="color: #000000; ">$)</span><span style="color: #000000; ">/</span><span style="color: #000000; ">g,&#160;</span><span style="color: #000000; ">""</span><span style="color: #000000; ">);&#160;<br />
</span><span style="color: #008080; ">10</span>&#160;<span style="color: #000000; "><br />
</span><span style="color: #008080; ">11</span>&#160;<span style="color: #000000; ">&#160;&#160;&#160;&#160;}&#160;</span></div>
<img src ="http://www.blogjava.net/liuyf8688/aggbug/313446.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/liuyf8688/" target="_blank">liuyf8688</a> 2010-02-20 13:47 <a href="http://www.blogjava.net/liuyf8688/articles/313446.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>