
On 14 July 2009, In jQuery, by Simon Dingley
Working on a project this morning and had some trouble finding a way to output the label for a checked radio button input control so thought I would share it in case it is of any use to someone else:
$('input[name=myRadioButtonListName]:checked + label').text()
Always interested to hear of any alternative/improved methods of achieving the same goal?
More From ProNotion
Related Posts
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.







7 Responses
Thanks! This helped me a lot!
Me too! Great help Sir.
Wow! Me too! Ferris Buehler, you’re my hero.
Is there any way to set the label of the radio button (dynamically) when opening the window.
[...] trying a few more tweaks that did not work, I found that getting the text of the labels for all radios would retrieve the checked value of each, in a string, delimited by a space. At last [...]
Kalana, if you know the id of the radio button element you should just be able to set the label value as follows:
$('your-element-id').text('Set your label text here');how to set radio button default selected on first value