views:

49

answers:

1

So far, I'm using

$(this).attr('class');

But I worry about compatibility because I know some browsers do some weird things with class and id attributes. Seems like a great place for jQuery to implement its own method, but I can't find it in the documentation.

Isn't there a bug somewhere that has className and id acting on the same objects? This may only apply to IE setting values, or maybe I'm just misremembering.

As meder pointed out, I was thinking of id and name, not id and class.

+2  A: 

.attr('class') would work out because internally it uses className

meder
But I recall hearing in a talk something to the effect that IE and maybe sometimes Opera will return the class *or* id when you use className. This may only apply to assignment, though.
sidewaysmilk
That's probably name and id.
meder
You could of course test this by trying to use `.attr('class')` in IE and Opera.
meder
@meder BINGO! Yes. You're right. Thanks very much.
sidewaysmilk