Andromeda
Andromeda

Reputation: 12897

Selecting class name of a span tag

I have a span like this

    <span class='class_name'> blah blah </span>

I want to select the class name of this span. for that iam using this.className its working fine in firefox. but for explorer its not...

How can i fix that??

Upvotes: 1

Views: 938

Answers (2)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039588

Is the variable this pointing to the same node in IE and Firefox? You could verify that by putting an alert(this.tagName) or alert(this.id).

Upvotes: 3

Paolo Bergantino
Paolo Bergantino

Reputation: 488744

That should be working in Explorer too. You could try, though:

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

Upvotes: 2

Related Questions