<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
input[type="text"]:enabled{
background-color:gold;
}
input[type="text"]:disabled{
background-color:dimgrey;
}
</style>
</head>
<body>
<script>
function radio_change(){
var radio1 = document.getElementById('radio1');
var radio2 = document.getElementById('radio2');
var text = document.getElementById('text');
if(radio1.checked){
text.disabled = "";
}else{
text.value = "";
text.disabled = "disabled";
}
}
</script>
<input type="radio" id="radio1" name="radio" onchange="radio_change()" />可用
<input type="radio" id="radio2" name="radio" onchange="radio_change()" />不可用
<input type="text" id="text" disabled />
</body>
</html>
版权声明:本文为zjsfdx原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。