日期:2014-05-18  浏览次数:20392 次

求一js,查找本页面中所有<input/>并隐藏它,在线等,实现了马上结帖
<input   id= "Text1 "   type= "text "/>
<input   id= "btnTest "   type= "button "/>
...
...
...
如题:查找input标记并隐藏,js

------解决方案--------------------
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
<script type= "text/javascript ">
function ChooseAll()
{
var inputs = document.all.tags( "INPUT ");
for (var i=0; i < inputs.length; i++) // 遍历页面上所有的 input
{
inputs[i].style.display = "none ";
}
return false;
}
</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<input id= "Text1 " type= "text "/>
<input id= "btnTest " type= "button "/>
<asp:Button ID= "btnCheck " runat= "server " Text= "Check " OnClientClick= "return ChooseAll(); "/>
</form>
</body>
</html>
------解决方案--------------------
貌似?没调试的

var a=document.getElementsByTagName( "input ");
for(var i=0;i <a.length;i++)
{
a[i].style.display= "none ";
}
------解决方案--------------------
上面的有点问题 呵呵
function s(){
var l=document.getElemetsByTagName( "input ");
for(var i=0,len=l.length;i <len;i++){
l[i].style.display= "none ";
}
}
------解决方案--------------------
同意这种方法

var a=document.getElementsByTagName( "input ");
for(var i=0;i <a.length;i++)
{
a[i].style.display= "none ";
}

------解决方案--------------------
<HTML>
<HEAD>
<TITLE> hide </TITLE>
<script language=javascript>
function hide()
{
var inputs = document.getElementsByTagName( "INPUT ");
for (var i=0; i <inputs.length; i++)
{
if (inputs[i].type== "text ")inputs[i].style.display= 'none ';
}
}
</script>
</HEAD>
<BODY>
<FORM name=form1 METHOD=POST ACTION= " ">
<INPUT TYPE= "text " NAME=txt>
<INPUT TYPE= "text " NAME=txt1>
<INPUT TYPE= "text " NAME=txt2>
<INPUT TYPE= "text " NAME=txt3>
<INPUT TYPE= "text " NAME=txt4>
<INPUT TYPE=button value= "隐藏 " onclick= "hide(); ">
</FORM>
</BODY>
</HTML>

------解决方案--------------------
既然星星都出手了,我就不重复了,来搞点新意

1.不用写js
<style>
input{display:none}
</style>

2.写js--觉得多余了点。
<style>
.css{display:none}
</style>

function foo(){
var o=document.getElemetsByTagName( "input ");
for(var i=0;i <o.length;i++){
o.classname= "css ";
}
}

------解决方案--------------------
function GetInput()
{
for(var i=0;i <window.Form1.children.length;i++)