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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:22:41+00:00 2026-05-16T08:22:41+00:00

I have some DIVs with ID div1, div2 … divx. I want to perform

  • 0

I have some DIVs with ID “div1”, “div2” … “divx”. I want to perform an operation on them. Is there any way to get the element ID .contains “div”. Any other idea?

  • 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-16T08:22:41+00:00Added an answer on May 16, 2026 at 8:22 am

    You can use the starts with selector

    $("div[id^='div']")
    

    The above will grab all divs that have an id attribute that begins with the letters div.

    jsFiddle example that makes all divs with id div... invisible.


    Here’s how to handle the trickier case if you want to match div followed by a number but not div followed by something else. So div1 would match, but divx would not.

    In this case we use filter() with a function. The function should return true for when we want a match and false for when we do not. match() and a regex is great for this (you can use [0-9] to represent a digit in a regex or the simpler [\d]):

    $("div").filter(function() {
        return $(this).attr("id").match(/^div[\d]+$/)
    })
    

    attr() returns the value of the specified attribute, in this case id.

    jsFiddle example that makes all div followed by number disappear, but not div followed by other things.

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

Sidebar

Related Questions

I have some DIVs with contents inside. I want to display them side by
I have some divs in my code and I want to loop them checking
I have some divs with divs in them, which I want to loop through
Scenerio: I have some divs populated through foreach loop like below <div id=div1><input type=hidden
I have some icons inside divs and needed to lay them out with a
I have some divs that I want to display under some specific conditions in
I have some divs with identical structure and i want to toggle when the
I have some trouble finding a way to position some divs next to each
I am using jQuery 1.4.3. I have some divs that have microdata in them
I have some divs holidng images I want to display. They are within a

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.