How to clear all labels under a div _ javascript tips-js tutorial

Source: Internet
Author: User
There are many ways to clear tags. The following is a good example to understand all the tags under the div. For more information, see The Code is as follows:


















The Code is as follows:


Function add1 () {// Add a p content-main
Var obj = document. createElement ("p ");
Obj. id = "content-main ";
Obj. innerHTML ='

'+
''+
'

';
$ ('# Slides'). append (obj );
}

Function clear () {// clear all p and img under slides
Var p1 = document. getElementById ("slides"). getElementsByTagName ("p ");
For (var I = 0; I P1 [I]. innerHTML = '';
}
}


The Code is as follows:


Function ClearAllText (pInput) {// clear the content of multiple text boxes in p and reset
Var txts = document. getElementById ('pinput'). getElementsByTagName ("input ");
For (var I = 0; I {
If (txts [I]. type = "text "){
Txts [I]. value = ""; // clear text
}
}
Var selects = document. getElementById ('pinput'). getElementsByTagName ("select ");
For (var I = 0; I {
Selects [I]. options [0]. selected = true; // select the first item
}
}

Related Article

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.