Clear all tags below div method _javascript Tips

Source: Internet
Author: User
Copy Code code 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 Code code 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 () {//Erase 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 Code code as follows:

function Clearalltext (divinput) {//empty div with more text text box contents, resetting
var txts = docu Ment.getelementbyid (' Divinput '). getElementsByTagName ("input");
for (Var i=0;i<txts.length;i++)
{
if (txts[i].type== "text") {
Txts[i].value = "";//text empty
}
}
var selects = document.getElementById (' Divinput '). getElementsByTagName ("select");
for (Var i=0;i<selects.length;i++)
{
selects[i].options[0].selected = true;//select First
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.