Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 283089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:20:38+00:00 2026-05-12T05:20:38+00:00

I would like the label associated with a radio button ‘hot’. I started to

  • 0

I would like the label associated with a radio button ‘hot’. I started to implement this using the .siblings() method. I think there must be a better way. The click event on the radio button looks like this:

$(".RadioButton").click(function(event) {

        var questionId = $(this).find('input').attr('name');
        var responseId = $(this).find('input').attr('value');
        var answerText = displayPopupQuizAnswer($(this));

This works great. I would like the same code to execute when the user clicks on the text label accompanying the radio button. The html looks something like this:

<div class="answers">
<span class="radiobutton>
<input type="radio" name="answer1"/>
</span>
<span class="answertextwrapper">
<a href="return false">this is the text</a>
</span>
</div>

This is simplified but it’s close. What I want is to capture the click event on the element with class=”answertextwrapper” i.e. $(“.answerwrapper”).click

So I need to somehow reference the input when the text is clicked. Make sense?

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T05:20:38+00:00Added an answer on May 12, 2026 at 5:20 am

    Simple, use actual label elements;

    When you use these, not only do you gain nice usability, but their click event is bound to the radio button’s click event. In otherwords, you don’t have to do any additional jQuery, just update your HTML.

    Here it is in action – if you have firebug you can clearly see that $(this) always refers to the <input>, regardless of whether or not you actually click on the corresponding <label>

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <title>test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
    <script type="text/javascript">
    
    $(function()
    {
      $('input.quiz-button').click( function( event )
      {
        console.log( $(this) );
      })
    } );
    
    </script>
    
    </head>
    <body>
      <form id="test" name="tester">
        <input class="quiz-button" type="radio" name="answer1" id="answer1"/>
        <label for="answer1">this is the text 1</label>
        <input class="quiz-button" type="radio" name="answer2" id="answer2"/>
        <label for="answer2">this is the text 2</label>
      </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like a button to change a label between being visible and not
I would like to set the MSMQ message label using the NetMsmqBinding. I understand
Using Rails, I would like to add: <span class='req'>&bull;</span> within my <label> tags in
I would like to create simple objects at runtime (textbox, label, etc) and add
I've got a multiline textBox that I would like to have a label on
Would like to get a list of advantages and disadvantages of using Stored Procedures.
I would like to label each of the boxes in a barplot by their
I would like a label instead of a textbox, is that possible. The code
I would like to make a UITableViewCell with one label and two accessory types:
I am using unobtrusive validation in an ASP.Net MVC3 app. I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.