input 有多种TYPE,我如何写一个style, 让它仅对 type=text 生效呢?
现在我只能定义一个class, 然后在所有的input type=text中用calss限定:
css:
input.MyTextBox {
......
}
HTML :
1<input ....="" class="MyTextBox" type="text"/>
---------------------------------------------------------------
.....
1<style>
2input { my:expression(doStyle(this))}
3</style>
1<script language="JavaScript">
2<!--
3function doStyle(e){
4if(e.type=="text") e.style.color="red";
5if(e.type=="password") e.style.color="blue";
6}
7//-->
8</script>
1<body>
2<input type="password"/>
3<input name="" type="text" value="abc"/>
4.....
5\---------------------------------------------------------------
6
7<style>
8.a {font-size: 12px; color: #FF00000}
9</style>
10<script language="javascript">
11var a = document.getElementsByTagName("input");
12for (var i=0; i<a.length; i++)
13{
14if(a[i].type=="text") a[i].className = "a"; //所有type=text的input都会用a这个样式了
15}
16</script></body>