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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:25:16+00:00 2026-05-26T21:25:16+00:00

I want to know how to write a jQuery selector to select each of

  • 0

I want to know how to write a jQuery selector to select each of the “input” items below. I do NOT want to select them all at once. These input boxes will not have names or ids. I probably must use some sort of child notation, but I’m not sure how to do it.

<div id="partdiv">
  <div class="floater">
    <input type="text"/> // Some input box with no id or name
  </div>
  <div id="descriptiondiv">
    <div class="floater">
      <input type="text"/> // Some input box with no id or name
    </div>
    <div id="positiondiv">
      <div class="floater"> 
        <input type="text"/> // Some input box with no id or name
      </div>
    </div>
  </div>
</div>

For the first one, for example , I tried:

    $("#partdiv > input").bind(....

but that did not work.

  • 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-26T21:25:17+00:00Added an answer on May 26, 2026 at 9:25 pm

    There are many different ways to do this – each with different tradeoffs. You can use these selectors:

    "#partDiv input:first"
    "#descriptiondiv input:first"
    "#positiondiv input"
    

    Or these:

    "#partDiv input:eq(0)"
    "#partDiv input:eq(1)"
    "#partDiv input:eq(2)"
    

    Or these:

    "#partDiv > .floater > input"
    "#descriptiondiv > .floater > input"
    "#positiondiv > .floater > input"
    

    Note, that the “proper” way to do this would be to give each input it’s own id or put it in a container that has an id (with no other input tags in the same container). Since neither of those is true, you have to use positional or hierarchy information to discern which input is which.

    Which of these different methods to use depends upon how tight or loose you want the relationship between your exact HTML structure and your selectors (e.g. whether the selector still works with certain types of changes to the HTML or not).

    The advantage to the first option is that it doesn’t care how many levels/layers of markup there are between the div and the input, only that you’re selecting the first input element in each div. Whereas the third option binds the selector to a very specific HTML implementation and if you put one extra div in between partDiv and the input, it would stop working. The first one would not stop working if you did that so the first and second are much less brittle than the third.

    The advantage of the second option is that it’s completely independent of the markup inside of partDiv. The only thing it cares about is the first, second and third input fields in that div.

    The main advantage of the third option is that you could rearrange the order of the three input fields and the selectors would still work as long as you maintained uniqueness of the hierarchy specified in the selector.

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

Sidebar

Related Questions

I want to know how to correctly write an if statement with jquery. I
OK, I know what you're thinking, "why write a method you do not want
I would like to know how could I write a jQuery selector that get
I want to write a real-time analysis tool for wireless traffic. Does anyone know
I want to write to a file in the windows temp directory. I know
I'm trying to write a new jQuery plugin. base (this is not my plugin,
I want to write some JQuery so that when I click the header 'Terms
I want to write a jQuery file uploading program, using this plug-in http://aquantum-demo.appspot.com/file-upload Despite
I know how to write a web-service but until now I used them with
I am extracting content from a web page using JS/JQuery and want to write

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.