使用单选按钮触发动作 [英] Using radio button to trigger an action
本文介绍了使用单选按钮触发动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在做一个项目,需要两个单选按钮进行日期选择.一个单选按钮获取系统日期并打印,但是另一个按钮在我选择时希望用户能够输入日期(基本上我想要当我单击第二个单选按钮时,将出现一个文本字段.)我是html编码的新手,所以如果有人可以帮助我,我了解了javascript和jquery,但我看到的示例无法提供任何帮助. 我已经添加了单选按钮
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 able to enter the date(basically I want a text field to appear when I click on the second radio button).I am new to html coding so please if anyone could help me.I read about javascript and jquery but the examples that I saw werent able to provide any help. I have already added the radio buttons
<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"/></td>
</table>
请有人给我一个主意.
推荐答案
<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>
然后在脚本下方写下
<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>
这篇关于使用单选按钮触发动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文