87,995
社区成员




<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<style type="text/css">
input{height:28px;line-height:28px;border:1px solid green;}
</style>
<script type="text/javascript">
function discolorStr(box)
{
document.getElementById(box).style.border ="1px solid red";
}
function discolorRes(box)
{
document.getElementById(box).style.border ="";
}
</script>
<body>
<div align="center" style="height:300px;line-height:300px;">
<input name="txta" id="txta" size="20" maxlength="20">
<input type="button" onClick="discolorStr('txta')" value="输入框变色">
<input type="button" onClick="discolorRes('txta')" value="恢复本色">
</div>
</body>
</html>
var str = "";
function discolorStr(box)
{
var obj = document.getElementById(box);
if (str == "")
str = (obj.currentStyle||getComputedStyle(obj,null)).borderColor;
obj.style.borderColor ="red";
}
function discolorRes(box)
{
var obj = document.getElementById(box);
obj.style.borderColor = str;
}
var str = "";
function discolorStr(box)
{
var obj = document.getElementById(box);
if (str)
str = (obj.currentStyle||getComputedStyle(obj,null)).borderColor;
obj.style.borderColor ="red";
}
function discolorRes(box)
{
var obj = document.getElementById(box);
obj.style.borderColor = str;
}