>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
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
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"
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
4 matches
Mail list logo