[jQuery] Re: Getting an elements classes

2007-04-23 Thread Dan G. Switzer, II
>I'm missing the blatantly obvious... > >jQuery can .addClass(), .removeClass(), and .toggleClass(). The following code would alert "true" if the #myElement had the class of "myClass". alert( $("#myElement").is(".myClass") ); -Dan

[jQuery] Re: Getting an elements classes

2007-04-23 Thread Aaron Heimlich
On 4/23/07, wls <[EMAIL PROTECTED]> wrote: How does one tell if an element has a class if( $("#myElement").is(".myClass") ) { // do super cool stuff... } or alternatively, get a list of classes? Try this: var classes = $("#myElement").attr("class").split(" "); -- Aaron Heimlich Web

[jQuery] Re: Getting an elements classes

2007-04-23 Thread Sam Collett
On Apr 23, 4:51 pm, wls <[EMAIL PROTECTED]> wrote: > I'm missing the blatantly obvious... > > jQuery can .addClass(), .removeClass(), and .toggleClass(). > > How does one tell if an element has a class, or alternatively, get a > list of classes? > > -wls You can do: if( $("#mydiv").is(".myclass"

[jQuery] Re: Getting an elements classes

2007-04-23 Thread Sean Catchpole
On 4/23/07, wls <[EMAIL PROTECTED]> wrote: How does one tell if an element has a class, or alternatively, get a list of classes? The following would return an array of the classes the first item has. var classes = $(query)[0].className.split(" "); ~Sean