<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> <br> <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=new Date(); <BR>var StartTime=Time.getTime(); <BR>for(var i=1;i<times;i++) <BR>{ <BR>var span=document.createElement('span'); <BR>span.appendChild(document.createTextNode(Text)); <BR>oDiv.appendChild(span); <BR>} <BR>var Time1=new Date(); <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=new Date(); <BR>var StartTime=Time.getTime(); <BR>for(var i=1;i<times;i++) <BR>{ <BR>oDiv.innerHTML+="<span>"+Text+""; <BR>} <BR>var Time1=new Date(); <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=new Date(); <BR>var StartTime=Time.getTime(); <BR>var MyArray=new Array(); <BR>for(var i=1;i<times;i++) <BR>{ <BR>MyArray.push("<span>"+Text+""); <BR>} <BR>oDiv.innerHTML=MyArray.join(' '); <BR>var Time1=new Date(); <BR>var EndTime=Time1.getTime(); <BR>document.getElementById('TbDate').value=EndTime-StartTime <BR>} <br><br>// --></script> <br> <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> <br><br> </div>