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

The Archive Base Latest Questions

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

<div id=’1′></div> <div id=’1_1′></div> <div id=’1_1_1′></div> <div id=’1_1_2′></div> <div id=’1_2′></div> <div id=’2′></div> <div id=’2_1′></div>

  • 0
<div id='1'></div>
<div id='1_1'></div>
<div id='1_1_1'></div>
<div id='1_1_2'></div>
<div id='1_2'></div>
<div id='2'></div>
<div id='2_1'></div>
<div id='2_2'></div>
<div id='2_2_1'></div>

Given this (psuedo) set of tags, I would like to be able to get all of the “level below” tags.
e.g.

id=1 gets 1_1 and 1_2, but not 1_1_1 etc.
id=2_2 gets 2_2_1 etc

I have tried the div[id^=1] but this returns all levels below.
Note, these are NOT nested tags, so Children doesn’t work 🙁

How can I restrict to just id_?

e.g. div[id=1_1_?]

Is there a single character wildcard, or a way of restricting the length of the selector?

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

    You could use the attribute starts-with selector you mentioned, and then filter the results:

    var elems = $("div[id^='1']").filter(function() {
        return this.id.length <= 3; 
    });
    

    Here’s a working example. Note that this also returns the div with just 1 as it’s id. You could prevent that by adding another condition to the return statement:

    var elems = $("div[id^='1']").filter(function() {
        return this.id.length <= 3 && this.id.length > 1; 
    });
    

    Finally, note that id values cannot start with a number unless you’re using the HTML5 doctype.

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

Sidebar

Related Questions

this div to cover up the viewport works perfect on IE 7, 8, FF,
I have an outside div, inside this is a lot of P elements and
Basically, what I'm trying to create is a page of div tags, each has
div { margin:90px auto; } This code centers the div in chrome with a
into DIV: <div id=materialcolor></div> I must incject this dynamically generated code: <select class=groupsmaterialcolorsDDs name=group_6
I am updating a div with a partial view by using something like this:
$('div#searchResult > div#searchResultItem > div#item').hover(function() { alert($(this).text()); }); Hi guys. Im doing a quick
The DIV elements height is not growing even after I set the height property
$('div#Categories > div.categories a#showhide').click(function(){ // Get the subManufacturers list var subCatList = $(this).parent().find('ul#hiddenSubCategories'); //
This div will have a computed height of 104.5px (in most recent Chrome, FF,

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.