【发布时间】:2014-05-12 12:22:00
【问题描述】:
当在我的表单上单击某个单选按钮时,我需要显示某些文本框,否则文本框应该保持隐藏状态。这是我所拥有的一个示例:
HTML:
Radio buttons:
<p>Show textboxes<input type="radio" name="radio1" value="Show" onClick="getResults()">Do nothing<input type="radio" name="radio1" value="Nothing"></p>
Textboxes:
<div class="text"><p>Textbox #1 <input type="text" name="text1" id="text1" maxlength="30"></p></div>
<div class="text"><p>Textbox #2 <input type="text" name="text2" id="text2" maxlength="30"></p></div>
jQuery:
$(document).ready(function() {
$(".text").hide()
function getResults() {
$(".text").show()
};
});
当我取出 .show() 代码时,文本框保持隐藏状态。当带有 onClick 事件的单选按钮被选中时,我需要显示它们。任何帮助将不胜感激。
【问题讨论】:
标签: javascript jquery html onclick radio-button