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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:16:17+00:00 2026-05-16T09:16:17+00:00

I just asked a question here about selecting all id’s of the form id_*

  • 0

I just asked a question here about selecting all id’s of the form id_* where * is any string and id is the id of the element. I got a great working solution:

$("*[id^=" + id + "_]").each(function() {... // id is the element name

I need to take this one step further now:
All of my ids will be of the form: a_b_c ... where a b and c are arbitrarity strings (that do NOT contain a ‘‘). So, now rather than selecting all the elems of the form id_* where * could be a_b_c ... I need only to select 1 level deep: i.e. all elems of the form id_a. So in other words it stops at the next ‘‘. Is this possible?

As an example:

If my id is: first
And there exist id’s: first_second, first_second_third
It will select only first_second

  • 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-16T09:16:18+00:00Added an answer on May 16, 2026 at 9:16 am

    What I ended up doing (and I’m open to faster implementations) is:

    $("*[id^=" + id + "_]").each(function() {
       //here I simply split the id and test the size of the array
       //if its too large (i.e. too deep in the tree), I return true (to continue
       //  to the next iteration):
    
       var row = $(this);
       var split = row.attr('id').split("_");
    
       if(split.length > SOME_PREDETERMINED_VAL)
          return true;
    
       //code here
    });
    

    I am not totally happy with this since it still traverses all elements (or would it do this anyway regardless of the filter in the each() function??).

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

Sidebar

Related Questions

I just asked a question here, about why an iframe_resize function wasn't working. After
So I recently asked a question about memoization and got some great answers, and
I was just about to ask the same questions as the question aksed here....
I asked a question [ here ] recently and it's just not providing me
Just asked a question about linking Boost libraries in the make file. Thanks to
I've just asked a question about an hour ago, while waiting for replies, I've
A while back, I asked a question on here about how to run an
I just asked a question about this but I want to go at it
A similar question was asked here in storing information in a given html element.
Yesterday I asked a question here about a oneliner and mjschultz gave me an

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.