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 7890641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:24:28+00:00 2026-06-03T06:24:28+00:00

I am running into this Jquery div show() hide() problem when you click on

  • 0

I am running into this Jquery div show() hide() problem when you click on a radio button. I have searched this forum and was able to get the function working but not for all the radio buttons. I have n number of radio buttons and when a user clicks on “Yes”, I want to display a div section. But the problem I am running into is this works correctly for the first radio button, the rest doesn’t respond to the clicks. Here is the js i am using

$(document).ready(function() {

    $('#isYes').click(function() {
        var test = $(this).val();
        alert(test)
        $("div.desc").hide();
        $('#divCheck').show();

    });

    $('#isNo').click(function() {

        $('#divCheck').hide();
    });

And my jsp code looks like

 <p>

           <td><core:out value="${obj.txt}" /> <form:radiobutton
                                            path="car[${Status.index}].carSelection"
                        value="isYes" onclick="" id="isYes" label="Yes" /> <form:radiobutton
                        path="car[${Status.index}].carSelection"
                        value="isNo" id="isNo" label="No" />
    </td>

</p>



     <div id="divCheck" class="desc({where desc is display: none;})">


                    <c:forEach items="${car.carList}" var="type"
                        varStatus="cstatus">

                        <form:checkbox path="carList[${cstatus.index}]"
                            value='${type.carName' />
                        <core:out value="${type.carName}" />
                        <br />

            </c:forEach>

            </div>

Why do the check boxes only display for the first radio button and not for the rest?

  • 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-06-03T06:24:30+00:00Added an answer on June 3, 2026 at 6:24 am

    As alexg stated, if you are using multiple id’s on a page, jquery will only find the first one. If you change it to a class. You will get back a selector with any number of elements with the class.

    This Works:

    <input class="isYes" type="radio">
    <input class="isYes" type="radio">
    var totalElements = $('.isYes').length; // 2
    

    This Wont:

    <input id="isYes" type="radio">
    <input id="isYes" type="radio">
    var totalElements = $('#isYes').length; // 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running into the strangest problem on iPhone using jQuery with my WebViewController. I have
I keep running into this design problem, and I'm not happy with my solution
I'm running into this problem when trying to call a SOAP Web Service from
I remember running into this problem when I started using OpenGL in OS X.
So I am running into this problem. I am trying to use $.get() to
I'm running into a problem with using Html.DropDownListFor() with jQuery. I'm using ASP.NET MVC
I'm running into trouble with this. I have a sticky header with a text
I'm building a simple image gallery with jquery but running into an annoying problem.
I keep running into this error MemCacheError (Broken pipe): Broken pipe on my Rails
I'm currently using Entity Framework and am running into this issue: The relationship between

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.