How To Get The Selected RadioButton From A List Of Element IDs Using jQuery
I've been doing some work with jQuery lately and now that I've begun digging into it am truly impressed at how much you can do with it so easily. Here's a quick line of code that will take a string of element IDs belonging to RadioButtons, find the one that's selected, and display an alert box with it's value:
alert("Selected radio button value: " + $(radioButtonIds).filter(":checked").get(0).value);
The format of the string containing the RadioButton IDs would look something like this:
"#rdoFirstChoice, #rdoSecondChoice, #rdoThirdChoice"
alert("Selected radio button value: " + $(radioButtonIds).filter(":checked").get(0).value);
The format of the string containing the RadioButton IDs would look something like this:
"#rdoFirstChoice, #rdoSecondChoice, #rdoThirdChoice"
Comments
Post a Comment