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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:31:40+00:00 2026-06-09T11:31:40+00:00

I have many div’s called each_item, one behind another. I am trying to check

  • 0

I have many div’s called “each_item”, one behind another.
I am trying to check whether a radio has been checked WITHIN this very div.

My problem is that with my jquery code (see below), all radio buttons of all “each_item” div’s are tested. I probably need to use $(this), but I don’t know how to use it in the selector I used below ( that is $('input:radio[name=gender]:checked'))

<div class='each_item'>
<input type='radio' name='gender' value='m'>
<input type='radio' name='gender' value='f'>

<input type='button' id='btn'>
</div>

The jquery i tried is this:

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

    if ($('input:radio[name=gender]:checked').length < 1)
        alert('nothing was checked');
    });

Thanks a lot if you could help me out.

  • 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-09T11:31:41+00:00Added an answer on June 9, 2026 at 11:31 am

    You can use find to only look within the div. closest will find the nearest ancestor with that class (the containing div).

    $('#btn').click(function(){
    
        if ($(this).closest(".each_item").find('input:radio[name=gender]:checked').length < 1)
            alert('nothing was checked');
        });
    
    });
    

    Also note that if you have multiple buttons with the same id, that is invalid and will likely cause you problems down the line. ids should always be unique.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many div.image , each one has a huge size. How do I
Good Afternoon, I have a html aspx page that has many many div elements.
I have divided the screen with many div so they stick one to each
I have a DIV with many elements that are all clickable. Each one with
I have many DIV with the same class name, let save wmplayer. I want
i have many div's with the same background image and i want change this
I want to append a div inside a div which have many divs inside
I have a menubar(div) which houses bookmarks and when too many bookmarks are inserted
I have many div in my aspx page. how to update the content of
i have many dragged div. is there is any way to get the id

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.