Copy codeThe Code is as follows:
<Div id = "slides">
<Div id = "content-main" name = "content-main">
<Div id = "a">
</Div>
</Div>
<Div id = "content-main" name = "content-main">
<Div id = "B">
</Div>
</Div>
</Div>
<Input id = "p" type = "button" value = "add" onclick = "add1 ();"/>
<Input id = "p" type = "button" value = "add33" onclick = "clear ();"/>
Copy codeThe Code is as follows:
Function add1 () {// Add a div content-main
Var obj = document. createElement ("div ");
Obj. id = "content-main ";
Obj. innerHTML = '<div id = "c">' +
'' +
'</Div> ';
$ ('# Slides'). append (obj );
}
Function clear () {// clear all div and img under slides
Var div1 = document. getElementById ("slides"). getElementsByTagName ("div ");
For (var I = 0; I <div1.length; I ++ ){
Div1 [I]. innerHTML = '';
}
}
Copy codeThe Code is as follows:
Function ClearAllText (divInput) {// clear the content of multiple text boxes in the div, reset
Var txts = document. getElementById ('divinput'). getElementsByTagName ("input ");
For (var I = 0; I <txts. length; I ++)
{
If (txts [I]. type = "text "){
Txts [I]. value = ""; // clear text
}
}
Var selects = document. getElementById ('divinput'). getElementsByTagName ("select ");
For (var I = 0; I <selects. length; I ++)
{
Selects [I]. options [0]. selected = true; // select the first item
}
}