给定一个带有2个单选按钮和textarea的简单HTML页面,我想在" No"时禁用textarea。单选按钮被选中。但以下内容从未禁用textarea。
<html>
<head>
<style>
.textwrapper
{
border:2px solid #999999;
margin:5px 0;
padding:3px;
}
</style>
<script type="text/javascript">
function disableText () {
if(document.getElementById("button2").checked) {
document.getElementById("summary").disabled = true;
}
else {
document.getElementById("summary").disabled = false;
}
}
</script>
</head>
<body>
Enter plot summary
<input type="radio" name="button1" id="button1" checked onclick="disableText()"> Yes
<input type="radio" name="button1" id="button2" onclick="disableText()"> No <br>
Plot summary <textarea class="textwrapper" name="plot" id="summary"></textarea>
</body>
</html>
答案 0 :(得分:0)
一些事情
- 将您的函数名称更改为disabledText
- 而不是disableText
-Declare与()
- function disabledText() { }