Home  >  Article  >  Web Front-end  >  javascript clears the value of a certain element in the form_form special effects

javascript clears the value of a certain element in the form_form special effects

WBOY
WBOYOriginal
2016-05-16 18:38:111366browse

Let’s take the case type="text" as an example:

Copy the code The code is as follows:







By calling the Refresh method of js
Method 1
Copy code The code is as follows:

function Refresh()
{
var v=document .forms[0].elements;
for(var i=0;i{
if(v[i].type=="text")
{
v[i].value="";
}
}

}

or method two
Copy code The code is as follows:

function Refresh()
{
var v=document.getElementsByTagName("input" );
for(var i=0;i{
if(v[i].type=="text")
{
v[ i].value="";
}
}
}

Clear the value of an element by calling the refresh function
Statement:
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