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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:23:40+00:00 2026-05-23T03:23:40+00:00

I have a markup like this: <div class=classA classB>the content</div> What I would like

  • 0

I have a markup like this:

<div class="classA classB">the content</div>

What I would like is a selector that selects all of the divs that start with classA and I did this:

$("div[class^='classA'");

but since I (for example) have also classes like:

<div class="classAsuffix">

that selector would grab this div also, and I do not want that.

So, I want a selector that will get me all of the divs that do start with classA but then after that have a space so in general: give me all divs which have “classA (space) someOtherClass”.

I hope I’m clear with my request. Thank you for your help!

Oh, forgot tot mention: I tried this:

$("div[class^='classA ']") but it doesn't 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-23T03:23:41+00:00Added an answer on May 23, 2026 at 3:23 am

    The quotes around your value should be double quotes, not single quotes. Actually, it doesn’t seem to matter. So:

    var matches = $('div[class^="classA "]');
    

    …which works with the latest jQuery. It matches an element with a class attribute starting with "classA " and so doesn’t match div class="classA" but does match div class="classA classB". But your version with single quotes works too. I’ve tried Chrome 11 (Linux & Windows), Firefox 3.6 (Linux), Firefox 4.0.1 (Windows), IE6, IE7, IE9, Opera 11 (Linux & Windows), and Safari 5 (Windows). I’ve tried jQuery 1.6.1 (the links above are to the “latest”), and jQuery 1.5.2. All gave the same result, finding only what I understand you want it to find.

    But — and this is slightly off-topic — I’d take a step back and look hard at why this need is coming up. It’s very unusual, which suggests there may be a better approach… Without knowing the underlying need, though, I could be wrong there.

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

Sidebar

Related Questions

If I have markup like this: <!-- Other Content --> <div id=container> <div class=draggable>
I have my markup like this (for argument's sake) <div id=content></div> <div id=layout></div> <div
I have a NodeSeq like this val article_template = <div> <div class=title></div> <div class=content></div>
I have this markup: <div class=myToggledDiv> <div>content</div> </div> <div style=margin-top: 10px;> content </div> Via
I have some markup like so: <div class=list> <article> content... </article> <article> content... </article>
I have some markup like this: <p><a id=1 href=#>Link 1</a></p> <p id=1show class=starthidden>Hi! I
I have the following markup. I would like to add class_A to <p class=subitem-text>
I would like to have a div which changes its content on the page
I have the following markup: <div class=FixedHeightContainer> <h2>Title</h2> <div class=Content> ..blah blah blah... </div>
I have this markup: <div id=container> <h1>Heading</h1> <p>Some text</p> <div class=foo>Some stuff</div> <div class=foo>Some

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.