代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>CSS3 Selector</title>
<style>
input[type="text"]:enabled{
background-color: yellow;
}
input[type="text"]:disabled{
background-color: dimgrey;
}
</style>
</head>
<body>
<script>
function radio_change(){
var radio1 = document.getElementById("radio11");
var radio2 = document.getElementById("radio2");
var text = document.getElementById("text");
var p = document.getElementById("p1");
if(radio1.checked){
text.disabled="";
text.value = "hello";
p.innerHTML = "haha";
}
else{
text.value = "";
text.disabled ="disabled";
}
}
</script>
<input type="radio" id="radio11" name="radio" onchange="radio_change()">use
<input type="radio" id="radio2" name="radio" onchange="radio_change()">unuse
<input type="text" id="text" disabled>
<p id="p1"></p>
</body>
</html>