Post Pic

Find the label for a selected radio button control using jQuery

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?

Related Posts

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

7 Responses

07.14.09

Thanks! This helped me a lot!

07.14.09

Me too! Great help Sir.

07.14.09

Wow! Me too! Ferris Buehler, you’re my hero.

07.14.09

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 [...]

07.14.09

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');
07.14.09

how to set radio button default selected on first value

Leave Your Response

* Name, Email, Comment are Required

Umbraco Certified Developer
FreshBooks
ElasticHosts: Flexible Servers in the Cloud
SagePay Approved Partner
Microsoft WebsiteSpark