<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta forua="true" http-equiv="Cache-Control" content="max-age=0" /></head>
<card title="js当某个文本框成为焦点时即清除文本框内容" id="card1">
<p> 游客</p><p>
标题:js当某个文本框成为焦点时即清除文本框内容<br/>
正文:<br/>
代码如下:<br/>&amp;lt;!doctype html&amp;gt; <br/>&amp;lt;html&amp;gt; <br/>&amp;lt;head&amp;gt; <br/>&amp;lt;meta charset=&quot;utf-8&quot;&amp;gt; <br/>&amp;lt;title&amp;gt;成为焦点时清除文本框内容&amp;lt;/title&amp;gt; <br/>&amp;lt;script&amp;gt; <br/>window.onload = initAll; <br/><br/>function initAll(){ <br/>var clearText = document.getElementsByTagName(&quot;input&quot;); <br/>for (var i=0; i&amp;lt;clearText.length; i++){ <br/>clearText[i].onfocus = function ( ){ <br/>this.value = &quot;&quot;; <br/>} <br/>} <br/>} <br/>&amp;lt;/script&amp;gt; <br/>&amp;lt;/head&amp;gt; <br/><br/>&amp;lt;body&amp;gt; <br/>文本框一：&amp;lt;input type=&quot;text&quot; name=&quot;text&quot; id=&quot;clearText1&quot; value=&quot;清除文本框一的内容&quot;/&amp;gt;&amp;lt;br/&amp;gt; <br/>文本框二：&amp;lt;input type=&quot;text&quot; name=&quot;text&quot; id=&quot;clearText2&quot; value=&quot;清除文本框二的内容&quot;/&amp;gt;&amp;lt;br/&amp;gt; <br/>文本框三：&amp;lt;input type=&quot;text&quot; name=&quot;text&quot; id=&quot;clearText3&quot; value=&quot;清除文本框三的内容&quot;/&amp;gt; <br/>&amp;lt;/body&amp;gt; <br/>&amp;lt;/html&amp;gt; <br/><br/><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1177&amp;Page=1">[&lt;&lt;]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1177&amp;Page=1">[[1]]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=1177&amp;Page=1">[&gt;&gt;]</a><br/>
<br/>
<a href="wap.asp?act=Com&amp;id=1177">查看评论(0)</a><br/>
<a href="wap.asp?act=AddCom&amp;inpId=1177">发表评论</a><br/><br/>

<br/>

<br/>
<a href="http://camnpr.com/wap.asp">首页</a>
</p>
</card>
</wml>