<div class="codetitle"> <span><a style="CURSOR: pointer" data="4815" class="copybut" id="copybut4815" onclick="doCopy('code4815')"><u>複製代碼</u></a></span> 代碼如下:</div> <div class="codebody" id="code4815"> <br> <br> <br> <br><meta charset="utf-8"> <br><title>成為焦點時清除文字框內容</title> <br><script> <BR>window.onload = initAll; <br> <br>function initAll(){ <BR>var clearText = document.getElementsByTagName("input"); <BR>for (var i=0; i<clearText.length; i ){ <BR>clearText[i]. onfocus = function ( ){ <BR>this.value = ""; <BR>} <BR>} <BR>} <BR></script> <br> <br><br> <br>文字方塊一:<input type="text" name="text" id="clearText1" value="清除文字方塊一的內容"><br> <br>文字方塊二:<input type="text" name="text" id="clearText2" value="清除文字方塊二的內容"><br> <br>文字方塊三:<input type="text" name="text" id="clearText3" value="清除文字方塊三的內容"> <br> <br> </div>