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

The Archive Base Latest Questions

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

Is it possible to combine both a class selector and an attribute selector with

  • 0

Is it possible to combine both a class selector and an attribute selector with jQuery?

For example, given the following HTML:

<TABLE>
  <TR class="myclass" reference="12345"><TD>Row 1</TD></TR>
  <TR class="otherclass" reference="12345"><TD>Row 2</TD></TR>
  <TR class="myclass" reference="12345"><TD>Row 3</TD></TR>
  <TR class="myclass" reference="54321"><TD>Row 4</TD></TR>
</TABLE>

What would be the selector I can use to select rows 1 and 3 only?

I have tried:

$(".myclass [reference=12345]") // returns nothing

$(".myclass, [reference=12345]") // returns all 4 rows (yes, I know the comma means 'or')

I’m sure the answer is very simple and I have tried searching the jQuery forums and documentation but I can’t seem to figure this one out. Can anyone help?

  • 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-22T23:41:35+00:00Added an answer on May 22, 2026 at 11:41 pm

    Combine them. Literally combine them; attach them together without any punctuation.

    $('.myclass[reference="12345"]')
    

    Your first selector looks for elements with the attribute value, contained in elements with the class.
    The space is being interpreted as the descendant selector.

    Your second selector, like you said, looks for elements with either the attribute value, or the class, or both.
    The comma is being interpreted as the multiple selector operator — whatever that means (CSS selectors don’t have a notion of “operators”; the comma is probably more accurately known as a delimiter).

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

Sidebar

Related Questions

Is it possible to combine registers in vim? For example, if I have registers
Is it possible to combine Ajax post with jQuery UI dialog? And I want
Consider the following simplified example and desired output: class A { class combined_iterator {
I'd like to take the following if possible and combine them: public static T[]
Is it possible to combine * syntax with table abbreviations? I want to do
Is it possible to combine two wav files into one as if they've been
Is it possible to combine a slideshow and show / hide div functionality? My
Also is it possible to combine this with removing periods from within the string?
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should
I want to count both the total # of records in a table, and

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.