CSS无法自动区分Input的type属性值。可以结合JS来判断:

 

<!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
<head>
<title> new document </title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<meta name="generator" content="editplus" />
<meta name="author" content="cnlei,枫岩,www.cnlei.net" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<link type="text/css" rel="stylesheet" href="" />
<style type="text/css" media="all">
 .InpTxt {color:#ccc;border:1px solid #eee; }
</style>

</head>
<body>
<form id="Form1" method="post" action="">
<input type="text" name="aa" value="text1" size="" maxlength="" />
<input type="text" name="bb" value="text2" size="" maxlength="" />
<input type="text" name="cc" value="text3" size="" maxlength="" /><br />
<input type="password" name="" value="password" size="" maxlength="" />
<input type="checkbox" name="" value="" />checkbox
<input type="button" class="btn" name="" value="button" />
</form>
<script type="text/javascript" language="javascript">
 <!--
  var arrInput=document.getElementById("Form1").getElementsByTagName("input");
  for(i=0;i<arrInput.length;i++) {
  if(arrInput[i].type=="text") {
   arrInput[i].className="InpTxt";
   alert(arrInput[i].value);  
   }
 }
 //-->
</script>
</body>
</html>

posted on 2006-06-05 11:35  许维光  阅读(358)  评论(0编辑  收藏  举报