单选按钮更改事件 [英] Radio Button Change Event
本文介绍了单选按钮更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个单选按钮(例如:ID和名称)。..
<%= Html.RadioButton(的Emp,1)%GT;
<标签>&ID LT; /标签>
&所述;%= Html.RadioButton(的Emp,2)%>
<标签>名称和LT; /标签>
如果我点击名称,
< P>
&所述;%:Html.LabelFor(M => m.MyDate)%GT;:&放大器; NBSP;
&所述;%:Html.EditorFor(M => m.MyDate)%GT;
&所述; / P>
以上控制应visibled false..How做到这一点。
解决方案
$(':无线电[值= 2])点击(函数(){
//可能需要调整选择设在这里
//在球场上,你想隐藏
$('#数值指明MyDate')隐藏()。
});
或者,如果你想使用 .change()
事件:
$(':无线电[名称=的Emp]')。改变(函数(){
//读取所选无线电的价值
VAR值= $(本).VAL();
如果(值=='2'){
$('#数值指明MyDate')隐藏()。
}
});
I am having 2 Radio Buttons.(For Ex : ID and Name)..
<%=Html.RadioButton("Emp","1")%>
<label>ID</label>
<%=Html.RadioButton("Emp","2")%>
<label>Name</label>
If i click the Name,
<p>
<%:Html.LabelFor(m => m.MyDate)%>:
<%:Html.EditorFor(m => m.MyDate) %>
</p>
the above control should be visibled false..How to do this.
解决方案
$(':radio[value=2]').click(function() {
// Might need to adjust the selector here based
// on the field you would like to hide
$('#MyDate').hide();
});
or if you want to use the .change()
event:
$(':radio[name=Emp]').change(function() {
// read the value of the selected radio
var value = $(this).val();
if (value == '2') {
$('#MyDate').hide();
}
});
这篇关于单选按钮更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文