The way to clear all tags under div

Source: Internet
Author: User

There are a lot of ways to

  clear labels, and here's a good example of all the tags below div, and the friends you need can refer to the following

  Code as follows: <div id= "Slides" >  <div id= "Content-main" name= "Content-main" >  <div id= "a" >& nbsp <img src= "Img/example-slide-1.jpg" alt= "1" >  </div>  </div>  <div id= " Content-main "Name=" Content-main ">  <div id=" B ">  <img src=" img/example-slide-2.jpg "alt=" 1 " >  </div>  </div>    </div>  <input id= "P" type= "button" value= "Add" Onclick= "Add1 ();" />  <input id= "P" type= "button" value= "add33" onclick= "clear ();" />    Code as follows: function Add1 () {///Add a div content-main  var obj=document.createelement ("div");  Obj.id= "Content-main";  obj.innerhtml= ' <div id= ' C ' > ' +  ' <img src= ' img/example-slide-3.jpg ' "alt=" 3 "> ' +  ' </div> ';  $ (' #slides '). Append (obj); }    function Clear () {// Clears all div and img  var div1=document.getelementbyid ("slides") under Slides. getElementsByTagName ("div");  for (Var i=0;i<div1.length;i++) {  div1[i].innerhtml= '; } }    code is as follows: function Clearalltext ( Divinput) {//empty div with more text text box contents, reset   var txts = document.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  } }  & nbsp

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.