<div class="codetitle"> <span><a style="CURSOR: pointer" data="93346" class="copybut" id="copybut93346" onclick="doCopy('code93346')"><u>复代码码</u></a></span> 代码如下:</div> <div class="codebody" id="code93346"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 전환//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br><html xmlns="http://www.w3.org/1999/xhtml" > <br><머리> <br><title>appendChild,innerHTML,join</title> <br><script type="text/javascript"><!-- <BR>//使用appendChild()수단법添加span标签 <BR>function AppendDiv() <BR>{ <BR>var times= parseInt(document.getElementById('tbTimes').value); <BR>var oDiv=document.getElementById('div1'); <BR>var Text=document.getElementById('tbText').value; <BR>var Time=새 날짜(); <BR>var StartTime=Time.getTime(); <BR>for(var i=1;i<times;i ) <BR>{ <BR>varspan=document.createElement('span'); <BR>span.appendChild(document.createTextNode(Text)); <BR>oDiv.appendChild(span); <BR>} <BR>var Time1=새 날짜(); <BR>var EndTime=Time1.getTime(); <BR>document.getElementById('TbDate').value=EndTime-StartTime <BR>} <BR>//使용innerhtml()방법添加span标签 <BR>function InnerHTML() <BR>{ <BR>var times =parseInt(document.getElementById('tbTimes').value); <BR>var oDiv=document.getElementById('div1'); <BR>var Text=document.getElementById('tbText').value; <BR>var Time=새 날짜(); <BR>var StartTime=Time.getTime(); <BR>for(var i=1;i<times;i ) <BR>{ <BR>oDiv.innerHTML ="<span>" 텍스트 "</span>"; <br>} <br>var Time1=새 날짜(); <br>var EndTime=Time1.getTime(); <br>document.getElementById('TbDate').value=EndTime-StartTime <br>} <br>//使用 Array中push添加span <br>function Join() <br>{ <br>var times=parseInt (document.getElementById('tbTimes').value); <br>var oDiv=document.getElementById('div1'); <br>var Text=document.getElementById('tbText').value; <br>var Time=새 날짜(); <br>var StartTime=Time.getTime(); <br>var MyArray=새 배열(); <br>for(var i=1;i<times;i ) <BR>{ <BR>MyArray.push("<span>" Text "</span>"); <br>} <br>oDiv.innerHTML=MyArray.join(' '); <br>var Time1=새 날짜(); <br>var EndTime=Time1.getTime(); <br>document.getElementById('TbDate').value=EndTime-StartTime <br>} <br><br>// --></script> <br></head> <br><본문> <br><input type="text" id="tbText" value="ws_hgo " /><br /> <br><input type="text" id="tbTimes" value="1000" /><br /> <br><input type="text" id="TbDate" /><br /> <br><input id="Button1" type="button" value="Append" onclick="AppendDiv();" /> <br><input id="Button2" type="button" value="innerHTML" onclick="InnerHTML();" /> <br><input id="Button3" type="button" value="Join" onclick="Join();" /> <br><div id="div1"> <br></div> <br></body> <br></html><br> </div>