我试图让这个函数显示/隐藏文本框元素。到目前为止,我运气不佳。谁能告诉我如何通过在您选择的单选选项上设置其样式可见或不挂起来显示和隐藏元素?这是我到目前为止所拥有的。
脚本
function hide(id)
{
document.getElementById(id).style.visibility='hidden';
}
function show(id)
{
document.getElementById(id).style.visibility='visible';
}
html
<div data-role="fieldcontain" data-theme="c" id="quests'+id+'">
<fieldset data-role="controlgroup" data-type="horizontal">
<label>Question?</label>
<input type="radio" name="radio1" id="'+QuestionID+'_1" value="1" onClick="show("comment_'+QuestionID+'")"/>
<label for="'+QuestionID+'_1">Yes</label>
<input type="radio" name="radio1" id="'+QuestionID+'_0" value="0" onclick="hide("comment_'+QuestionID+'")"/>
<label for="'+QuestionID+'_0">No</label>
</fieldset>
//I am trying to make these visable if yes is selected
<textarea cols="30" rows="8" name="textarea" style="width:80%; visibility:hidden;" id="comment_'+QuestionID+'"></textarea>
<br />
</div>
谢谢!