简体   繁体   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>

Is what i have. 是我所拥有的。

How can i show #warning_custom when you choose "manual" and #warning_auto when you choose "auto"? 选择“手动”时如何显示#warning_custom,选择“自动”时如何显示#warning_auto?

And if you choose #warning_custom(manual) then the #warning_auto should hide and same should happen the opposite way. 而且,如果您选择#warning_custom(manual),则#warning_auto应该隐藏,并且应该以相反的方式发生。

How can i do this? 我怎样才能做到这一点? I tried but i cant manage to so the one shows only and the other hides again.. 我试过了,但我设法做到了,一个只显示,另一个又隐藏了。

I'm guessing as to what the rest of your code looks like: 我在猜测其余的代码是什么样的:

$("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