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

  • Home
  • SEARCH
  • 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 795109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:25:32+00:00 2026-05-14T22:25:32+00:00

I have the following HTML structure <div id=test-1-yay></div> … bunch of code … <div

  • 0

I have the following HTML structure

<div id="test-1-yay"></div>
... bunch of code ...
<div id="test-2-yay"></div>
... bunch of code ...
<div id="test-3-yay"></div>

I was wondering how I can use jQuery to basically identify each of these “id’s” and then apply some jQuery to them ? I’m new to this so little unsure ? Something like

if $('#test-1-yay' || '#test-2-yay' || '#test-3-yay') {
do stuff to all ID's
}

But the prob is I want this to continue as it could go to #test-201-yay, #test-202-yay etc ?

Thx

  • 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-14T22:25:33+00:00Added an answer on May 14, 2026 at 10:25 pm

    You could use a substring selector to get most of the way there:

    var divs = $('div[id^=test-]'); // All divs with IDs starting with "test-"
    

    …which would work better if you changed the naming convention a bit so the number was at the end. But I think I’d lean toward using some other aspect of the structure (the parent node), or a class, or a data-xyz attribute…

    Edit A pair of substring selectors can do it:

    var divs = $('div[id^=test-]').filter("div[id$=yay]");
    

    That gets all of the ones whose IDs start with “test-” and then filters out the ones that don’t end with “yay”. Close, anyway…

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

Sidebar

Related Questions

I have a question. I use jquery superfish menu with the following structure <div
I have the following html structure <div id=rn_answertext> <p>asdasdasdas</p> <p>asdasdasdas</p> <p>asdasdasdas</p> <h3>asdasdasdas</h3> <div id=test>Content
I have a jQuery slideshow code that works fine with the following HTML structure:
I have the following HTML node structure: <div id=foo> <div id=bar></div> <div id=baz> <div
i have following HTML structure: <div class=container> <div class=sidebar></div> <div class=content></div> <div class=subscript></div> </div>
I have the following html structure <div style=overflow-x:auto;overflow-y:hidden;position:relative> <div style=position:absolute; top:0;bottom:0;padding-top:30px> </div> </div> When
I have the following HTML structure: $('#subgroup a').nextUntil('h3').wrapAll('<div></div>'); <script src=https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js></script> <div id=subgroup> <h3>Group name
I have the following HTML structure: <div><a href=link1>blah</a></div> <div><a href=link2>blah</a></div> <div><a href=link3.swf>blah</a></div> <div><a href=link4>blah</a></div>
i have following html structure. <p class=expandableContent ><span class=label>Computer and Laptop Repairs</span></p> <div style=clear:
I have following html site structure: <body> <div id=header></div> <div id=container> <div id=util_header></div> <div

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.