Home > Web Front-end > JS Tutorial > JavaScript client traversing controls and obtaining parent container object sample code_javascript skills

JavaScript client traversing controls and obtaining parent container object sample code_javascript skills

WBOY
Release: 2016-05-16 17:05:08
Original
1234 people have browsed it

1, traverse all the controls in the surface
function findControlAll()
{
var inputs=document.getElementsByTagName("input");
for(j=0;j if(inputs[j].type=="text") //Here, find all the controls of type text on the page, you can also Set the type of control you want to traverse
{
inputs [j]. Value = "" "; // Clear the content of the text box
}
}
2 , traverse the controls in the specified container
function findControl()
{
// table1 below refers to traversing the controls in the table
var inputs = document.getElementById( "table1").getElementsByTagName("input");
for(var i=0;i {
if(inputs[i].type=="text" )//Same as above, the type of control and the operations to be done can be filled in as needed
                                                                                                                                                                                                                                  🎜>


Get the parent container object


Copy code

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template