Klaus Hartl wrote:
Christopher Jordan schrieb:
Hi folks,

How can I tell what class (or classes) an element has? For instance I've got an elements like:

<div class="classA classB"></div>
<div class="classA classC"></div>

How can I select all elements that have classA and ClassB but not classC?

$('div.classA, div.classB').not('.classC')

In case you want only elements that are of classA and classB use this:

$('div.classA.classB')
I had tried something like this, but didn't get the syntax quite right. I wasn't caring about the div part of it and just said:
$(.classA .classB)... with a space.

I'd also like to know how to select all items of a certain class and attribute. For instance:

<div class="classA" Status="On"></div>
<div class="classA" Status="Off"></div>
<div class="classA" Status="Off"></div>
<div class="classA" Status="On"></div>
<div class="classA" Status="Off"></div>
<div class="classA" Status="Off"></div>

I want jQuery to match all the elements that are of classA and that have the Status attribute set to "On". How would I do that?

$('div.classA').filter('[EMAIL PROTECTED]"On"]')
Ah! I looked at contains... didn't even see filter. My eyes must have just passed over it in scanning the API.

Thanks heaps, Klaus! I really appreciate it! :o)

Cheers,
Chris

--
http://www.cjordan.info

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to