Copy codeThe Code is as follows:
<! 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"> <! --
// Use appendChild () to add a span tag
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
}
// Use the innerhtml () method to add a span tag
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
}
// Add span using push in Array
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
}
// --> </Script>
</Head>
<Body>
<Input type = "text" id = "tbText" value = "ws_hgo"/> <br/>
<Input type = "text" id = "tbTimes" value = "1000"/> <br/>
<Input type = "text" id = "TbDate"/> <br/>
<Input id = "Button1" type = "button" value = "Append" onclick = "AppendDiv ();"/>
<Input id = "Button2" type = "button" value = "innerHTML" onclick = "InnerHTML ();"/>
<Input id = "Button3" type = "button" value = "Join" onclick = "Join ();"/>
<Div id = "div1">
</Div>
</Body>
</Html>