您的位置:首页 > Web前端 > CSS

[网摘]如何用CSS控制input标签

2009-06-28 04:58 597 查看
1.

.....
<style>
input { my:expression(doStyle(this))}
</style>
<script language="JavaScript">
<!--
function doStyle(e){
if(e.type=="text") e.style.color="red";
if(e.type=="password") e.style.color="blue";
}
//-->
</script>
</head>
<body>
<input type="password">
<input type="text" name="" value="abc">

2.
.....

<style>
.a {font-size: 12px; color: #FF00000}
</style>

<script language=javascript>
var a = document.getElementsByTagName("input");
for (var i=0; i<a.length; i++)
{
if(a[i].type=="text") a[i].className = "a"; //所有type=text的input都会用a这个样式了
}
</script>

.....
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: