funcation changecolor(){
document.getElememtById("mytext").style.bodercolor="red"
}
<script>
<body>
<input type="text" value="aaa" id="mytext" onmouseover="changecolor()"/>
<body>
默认的边框样式应该是无法恢复的,不同浏览器的边框也不一样。
不过你可以在文本框外面加一个span,只改变span的边框(需要调整一下padding),这样就可以恢复了:
<html><head>
<script type="text/javascript">
var t = 0
function showBorder() {
var answer3 = document.getElementById("yearId").value
if (t == 0) {
t = 1
document.getElementById("yearId").parentElement.style.border = "0"
}
else {
t = 0
document.getElementById("yearId").parentElement.style.border = "1px solid black"
}
}
</script>
</head>
<body>
<span style="padding-bottom: 2px padding-top: 1px padding-left: 0 padding-right: 0">
<input type="text" id="yearId" name="yearId" size="16" /></span>
<input type="button" value="show border" onclick="showBorder()" />
</body>
</html>
效果图: