<small id='DLjml'></small><noframes id='DLjml'>

    • <bdo id='DLjml'></bdo><ul id='DLjml'></ul>

  1. <legend id='DLjml'><style id='DLjml'><dir id='DLjml'><q id='DLjml'></q></dir></style></legend>

      <tfoot id='DLjml'></tfoot>
      <i id='DLjml'><tr id='DLjml'><dt id='DLjml'><q id='DLjml'><span id='DLjml'><b id='DLjml'><form id='DLjml'><ins id='DLjml'></ins><ul id='DLjml'></ul><sub id='DLjml'></sub></form><legend id='DLjml'></legend><bdo id='DLjml'><pre id='DLjml'><center id='DLjml'></center></pre></bdo></b><th id='DLjml'></th></span></q></dt></tr></i><div id='DLjml'><tfoot id='DLjml'></tfoot><dl id='DLjml'><fieldset id='DLjml'></fieldset></dl></div>

      选择单选按钮时显示 div

      Show div when radio button selected(选择单选按钮时显示 div)
        <tbody id='1OELI'></tbody>
      • <bdo id='1OELI'></bdo><ul id='1OELI'></ul>

        <small id='1OELI'></small><noframes id='1OELI'>

          <tfoot id='1OELI'></tfoot>
          • <legend id='1OELI'><style id='1OELI'><dir id='1OELI'><q id='1OELI'></q></dir></style></legend>
              1. <i id='1OELI'><tr id='1OELI'><dt id='1OELI'><q id='1OELI'><span id='1OELI'><b id='1OELI'><form id='1OELI'><ins id='1OELI'></ins><ul id='1OELI'></ul><sub id='1OELI'></sub></form><legend id='1OELI'></legend><bdo id='1OELI'><pre id='1OELI'><center id='1OELI'></center></pre></bdo></b><th id='1OELI'></th></span></q></dt></tr></i><div id='1OELI'><tfoot id='1OELI'></tfoot><dl id='1OELI'><fieldset id='1OELI'></fieldset></dl></div>

              2. 本文介绍了选择单选按钮时显示 div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我是 javascript 和 jQuery 的新手.在我的 html 中有 2 个单选按钮和一个 div.如果我检查第一个单选按钮,我想显示该 div,否则我希望它被隐藏

                I am novice in javascript and jQuery. In my html have 2 radio buttons and one div. I want to show that div if I check the first radio-button but otherwise I want it to be hidden

                so: 如果选中单选按钮#watch-me --> div #show-me 可见.如果单选按钮#watch-me 未选中(既未选中也未选中第二个)--> div #show-me 被隐藏.

                so: If radio button #watch-me is checked --> div #show-me is visible. If radio button #watch-me is unchecked (neither are checked or the second is checked) --> div #show-me is hidden.

                这是我目前所拥有的.

                 <form id='form-id'>
                <input id='watch-me' name='test' type='radio' /> Show Div<br />
                <input name='test' type='radio' /><br />
                <input name='test' type='radio' />
                 </form>
                 <div id='show-me' style='display:none'>Hello</div>
                

                和 JS:

                 $(document).ready(function () { 
                $("#watch-me").click(function() {
                 $("#show-me:hidden").show('slow');
                 });
                 $("#watch-me").click(function(){
                 if($('watch-me').prop('checked')===false) {
                    $('#show-me').hide();}
                    });
                });
                

                我应该如何更改我的脚本来实现这一点?

                How should I change my script to achieve that?

                推荐答案

                我会这样处理:

                $(document).ready(function() {
                   $('input[type="radio"]').click(function() {
                       if($(this).attr('id') == 'watch-me') {
                            $('#show-me').show();           
                       }
                
                       else {
                            $('#show-me').hide();   
                       }
                   });
                });
                

                这篇关于选择单选按钮时显示 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                keeping radio buttons checked after form submit(表单提交后保持选中单选按钮)
                Bootstrap radio button quot;checkedquot; flag(Bootstrap 单选按钮“已选中旗帜)
                Toggle HTML radio button by clicking its label(通过单击标签来切换 HTML 单选按钮)
                Javascript how to change radio button label text?(Javascript如何更改单选按钮标签文本?)
                JavaScript radio button confirmation(JavaScript 单选按钮确认)
                How can I automatically select specific radio buttons with Greasemonkey?(如何使用 Greasemonkey 自动选择特定的单选按钮?)

                    <legend id='TxYIi'><style id='TxYIi'><dir id='TxYIi'><q id='TxYIi'></q></dir></style></legend>

                  • <tfoot id='TxYIi'></tfoot>
                    • <bdo id='TxYIi'></bdo><ul id='TxYIi'></ul>

                    • <i id='TxYIi'><tr id='TxYIi'><dt id='TxYIi'><q id='TxYIi'><span id='TxYIi'><b id='TxYIi'><form id='TxYIi'><ins id='TxYIi'></ins><ul id='TxYIi'></ul><sub id='TxYIi'></sub></form><legend id='TxYIi'></legend><bdo id='TxYIi'><pre id='TxYIi'><center id='TxYIi'></center></pre></bdo></b><th id='TxYIi'></th></span></q></dt></tr></i><div id='TxYIi'><tfoot id='TxYIi'></tfoot><dl id='TxYIi'><fieldset id='TxYIi'></fieldset></dl></div>

                        <small id='TxYIi'></small><noframes id='TxYIi'>

                          <tbody id='TxYIi'></tbody>