我有两个单选按钮,一个用于 section 1
和一个用于 section 2
,
而默认选择的radion按钮是 section 1
,并显示一些文字,但当客户端点击了 section 2
下面没有文字,那是为了说明我的网页。
[*] section 1 [ ] section 2
- section one text when checked radio button
----------------------------------------------
[ ] section 1 [*] section 2
// none text here when section two checked
< Button >
当点击按钮后选择第2节,并进入另一个页面,然后返回到该节页面时,文字的内容是:"我想知道你是怎么想的"。section one text when checked radio button
显示思想的单选按钮检查 section 2
如何隐藏这些文字(section one text when checked radio button
)的时候,客户端返回该页面,但在该页面上勾选了 section 2
还在检查吗?
这在我的Rails应用上发生了
你可以根据你的变量值,给包含文字的span添加一个类。例如,你可以做成这样。
<span class="<%= hide if @variable =='section 2 value' %>">
- section one text when checked radio button
</span>
如果我猜对了你想做什么。 是根据点击哪个单选按钮来显示文本的东西. 不如把HTML分割成divs,然后在点击时显示隐藏这两个divs的id。
当第1节被点击时。
$('#add-doc-modal #show-section1').show();
$('#add-doc-modal #show-section2').hide();
当第2节被点击时
$('#add-doc-modal #show-section2').show();
$('#add-doc-modal #show-section1').hide();
如果这是你的问题,我的意思是,这不是最容易阅读的。
隐藏单选按钮并设置为false。
document.getElementById("#id").style.display = "none";
$("#id").prop("checked", false);
要显示单选按钮
document.getElementById("#id").style.display = "block";
$("#id").prop("checked", true);