【发布时间】:2015-10-19 19:37:29
【问题描述】:
这是我的代码:
HTML:
<span id="opc1"> <input type="radio" name="radio_relatorio" id="tipo_relA" value="A"> A </span>
<span id="opc2"> <input type="radio" name="radio_relatorio" id="tipo_relS" value="S"> S </span>
Javascript:
$("select[name=tprel]").change(function() {
document.getElementById("tpbaixa").selectedIndex = 0;
muda_label_datas($(this).val());
if($(this).val() == 18)
{
$("#opc2").css("display","block");
$("#opc1").css("display","none");
$("#tipo_relS").attr('checked', true);
}
else
{
$("#opc2").css("display","none");
$("#opc1").css("display","block");
$("#tipo_relS").attr('checked', false);
} // it's an large function, but that's what matter
});
change函数下有两个Radio,#tipo_relS和#tiporelA。无线电#tiporelA 在onload 功能上进行检查。当 option 的值为 18 时,radio #tiporelA 为 display none,#tiporelS 为 display block。
我需要检查此单选按钮 #tiporelS 而 #tiporelA 不显示,但似乎没有任何效果。
【问题讨论】:
-
你的描述和代码不匹配!可能会在小提琴中复制您的问题。
-
您能否提供更大的代码上下文?您正在寻找的行为究竟是什么?你检查#tiporelS 是为了什么?
-
正如@lshettyl 所说,您发布的代码与您要求的代码不匹配。
-
有什么建议可以改写答案吗?
标签: javascript jquery radio-button