单选按钮检查的事件处理 [英] Radio button checked event handling
本文介绍了单选按钮检查的事件处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的申请中,我需要一个无线电基团,其中每当无线电按钮被选中,警报发生,这样我可以它的值张贴到AJAX交与jQuery.
In my application, I need a radio group, in which whenever a radio-button is checked, an alert occur so that I can post it's value to ajax post with jQuery.
您能帮我在jQuery中做些什么吗?
Can you help me please how i can do it in jQuery?
推荐答案
尝试如下操作:
$(function(){
$('input[type="radio"]').click(function(){
if ($(this).is(':checked'))
{
alert($(this).val());
}
});
});
如果为单选按钮提供一个类,则可以将代码$('input[type="radio"]')
替换为$('.someclass')
.
If you give your radio buttons a class then you can replace the code $('input[type="radio"]')
with $('.someclass')
.
这篇关于单选按钮检查的事件处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文