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.
Can you help me please how i can do it in 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.
Can you help me please how i can do it in jQuery?
The HTML code:
The Javascript code:
In multiple radio with name "theName", detect when option 1 is checked or unchecked. Works in all situations: on click control, use the keyboard, use joystick, automatic change the values from other dinamicaly function, etc.
Update in 2017: Hey. This is a terrible answer. Don't use it. Back in the old days this type of jQuery use was common. And it probably worked back then. Just read it, realize it's terrible, then move on (or downvote or, whatever) to one of the other answers that are better for today's jQuery.
Try something like this:
If you give your radio buttons a class then you can replace the code
$('input[type="radio"]')
with$('.someclass')
.You can simply use the method
change
of JQuery to get the value of the current radio checked with the following code:JQuery:
You can change the selector
'[type="radio"]'
for a class or id that you want.Regards!