1

I have this HTML:

<input class="radio" type="radio" name="which_app" value="" id="whichApp1" required>
<label class="left-narrow" for="whichApp1">Program #1</label><br />
<input class="radio" type="radio" name="which_app" value="" id="whichApp2">
<label class="left-narrow" for="whichApp2">Program #2</label>

I have this script:

$( 'input[type=radio][name=which_app]' ).change( function() {
  var label = $("label[for='"+$(this).attr('id')+"']");
  alert( label );
}

I get this pop-up alert:

enter image description here

How can I decode the [object Object] to get the label that was clicked on? (there are other reasons for not using value="" at this time so I am trying to focus solely on the label. Thank you)

1 Answer 1

5

Use this

alert(label.html());

or

to get the text

alert(label.text());

Sign up to request clarification or add additional context in comments.

4 Comments

Can't accept answer for another 10 mins...so I'll accept in the future sometime (stupid SO)
I can wait 10 mins :)
Wow! Longest 10 mins ever.
Is the 10 mins up yet??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.