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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:25:46+00:00 2026-06-14T17:25:46+00:00

OK, I want to set margin for the second div on the page using

  • 0

OK, I want to set margin for the second div on the page using

$('div#superid:nth-child(2)').css('margin-left', '10px');

Everything works find, I’ve reached the goal. But, I want that rule applied ONLY if this div contains at least one input radio with name superchild.
So, the rule above should apply to:

<div id="superid">
   <div>some text
   </div>
   <div>
    <input type="radio"  name="superchild" value="2010">
    <input type="radio"  name="superchild" value="2010">
   </div>
</div>

because it has at least one input radio with name="superchild"
What’s the best way to do that?

  • 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-14T17:25:49+00:00Added an answer on June 14, 2026 at 5:25 pm

    You could also use the filter method.
    The script below selects every div in the #superid-div, which has at least one input field of type radio and name superchild. Then it adds the desired css to the selected divs.

    $('div#superid > div').filter( function(index,elem) {
        return $(this).find('input[type=radio][name=superchild]').length > 0;
    }).css('margin-left', '10px');
    

    jsFiddle

    If you want do add this style ONLY to the second div, use your selector instead. But I thought my script covers the desired behaviour better.

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

Sidebar

Related Questions

i am using android:layout_marginTop=100dip in my imageview,i want to set margin top to each
My question is : I have an EditText and I want set a margin
I want to get print out invoice but also wanna set margins and page
i have a multiple marker Google map, it works fine but i want set
I want to set left and right margins on popupwindow. I try setting layout
I want that when I set margin bottom, which makes part of the view
I want to set start margin only for the first line of TextView (Not
I am using Twitter Bootstrap, but can't understand How to set margin 0 0
<table> <tr> <td> <div style=margin-left: 220px;> <asp:Button ID=btn1 Text=Edit CommandArgument='<%#Eval(UserID) %>' CausesValidation=false CommandName=Edit Visible=false
I am a novice in web developing. My container div is set to margin:

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.