[SOLVED]CSS class selector.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

[SOLVED]CSS class selector.

Post by JellyFish »

What CSS class selector does jQuery support that allows me to select an element with two classes? For example let's say I had multiple elements that have the class "top". And in that set of elements each has the class "left", "center" and "right", respectfully. How would I select the element that has both the "top" class and the "center" class?

Code: Select all

$(".top left")
This doesn't really cut the cake.

Is there a way to do this?
Last edited by JellyFish on Tue Jan 15, 2008 12:03 am, edited 1 time in total.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: CSS class selector.

Post by RobertGonzalez »

What you are doing should work, just remember to reference them correctly, using the . before the class name for both.
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: CSS class selector.

Post by Kieran Huggins »

Code: Select all

$(".classone.classtwo")
Check out http://docs.jquery.com/Selectors for more
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Re: CSS class selector.

Post by JellyFish »

Kieran Huggins wrote:

Code: Select all

$(".classone.classtwo")
Check out http://docs.jquery.com/Selectors for more
Thanks Kieran, this is what I was looking for.
Post Reply