繁体   English   中英

如何在选定的单选按钮上显示元素?

[英]How to show elements on selected radio buttons?

        <input id="auto" type="radio" name="warning_type" value="auto"> <label for="auto">Auto-varning</label> <br>
        <input id="manual" type="radio" name="warning_type" value="custom"> <label for="custom">Custom</label> <br>

是我所拥有的。

选择“手动”时如何显示#warning_custom,选择“自动”时如何显示#warning_auto?

而且,如果您选择#warning_custom(manual),则#warning_auto应该隐藏,并且应该以相反的方式发生。

我怎样才能做到这一点? 我试过了,但我设法做到了,一个只显示,另一个又隐藏了。

我在猜测其余的代码是什么样的:

$("input:radio").click(function() {
    if ($(this).val()=="auto") {
        $("#warning_custom").hide();
        $("#warning_auto").show();
    } else {
        $("#warning_auto").hide();
        $("#warning_custom").show();
    }
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM