Friday 4 March 2011

jQuery: Find the label text for a selected radio button

Sometimes the seemingly easiest pieces of code can end up giving you trouble.  This morning I was working on a project where I wanted to display the text (not the value) of a selected radio button.

In the end it was very simple.  I added a label to my radio buttons and used the following line of code.

$('input[name=myname]:checked + label').text();


Post a Comment


Popular Posts

developer-express Copyright © 2009 Black Nero Blogspot Templatesis Designed by Ipietoon Sponsored by Online Business Journal