<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>appendChild,innerHTML,join</title> <script type="text/javascript"><!-- //使用appendChild()方法添加span标签 function AppendDiv() { var times=parseInt(document.getElementById('tbTimes').value); var oDiv=document.getElementById('div1'); var Text=document.getElementById('tbText').value; var Time=new Date(); var StartTime=Time.getTime(); for(var i=1;i<times;i++) { var span=document.createElement('span'); span.appendChild(document.createTextNode(Text)); oDiv.appendChild(span); } var Time1=new Date(); var EndTime=Time1.getTime(); document.getElementById('TbDate').value=EndTime-StartTime } //使用innerhtml()方法添加span标签 function InnerHTML() { var times=parseInt(document.getElementById('tbTimes').value); var oDiv=document.getElementById('div1'); var Text=document.getElementById('tbText').value; var Time=new Date(); var StartTime=Time.getTime(); for(var i=1;i<times;i++) { oDiv.innerHTML+="<span>"+Text+"</span>"; } var Time1=new Date(); var EndTime=Time1.getTime(); document.getElementById('TbDate').value=EndTime-StartTime } //使用 Array中push添加span function Join() { var times=parseInt(document.getElementById('tbTimes').value); var oDiv=document.getElementById('div1'); var Text=document.getElementById('tbText').value; var Time=new Date(); var StartTime=Time.getTime(); var MyArray=new Array(); for(var i=1;i<times;i++) { MyArray.push("<span>"+Text+"</span>"); } oDiv.innerHTML=MyArray.join(' '); var Time1=new Date(); var EndTime=Time1.getTime(); document.getElementById('TbDate').value=EndTime-StartTime }