Using radio button to trigger an action

后端 未结 2 675
长情又很酷
长情又很酷 2021-01-27 00:22

I am doing a project where I need two radio buttons for date selection.One radio button takes the system date and prints but the other button when I select,I want the user to be

相关标签:
2条回答
  • 2021-01-27 00:56
    <table border="1" width="100%">
    <tr>
     <th> Date</th>
    </tr>
    <td>
      Current date<input type="radio" name="zing" id="foo" checked/>
      Add date<input type="radio" name="zing" id="bar"/>
    <input type='text' id='txtDate' style='display:none'/>
    </td>
    </table>
    

    then write down below script

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ></script>
    <script>
    $(document).ready(function(){
      $("#bar").change(function(){
           $("#txtDate").show();
      });
    $("#foo").change(function(){
           $("#txtDate").hide();
      });
    });
    </script>
    
    0 讨论(0)
  • 2021-01-27 01:12

    Try this

     $(function(){
          $("input:radio:first").click();
        });
    
    0 讨论(0)
提交回复
热议问题