Blankman
Blankman

Reputation: 267000

Why does $('someObject').attr("id")[0] not work in IE?

The following jquery code works in firefox, but is returning undefined in IE:

$('someObject').attr("id")[0]

Why is that?

Upvotes: 0

Views: 196

Answers (1)

Tamas Czinege
Tamas Czinege

Reputation: 121314

Try

$('someObject').attr("id").charAt(0)

The [] indexer operator is not supported on strings in Internet Explorer. string::charAt() is the correct method to use.

Upvotes: 10

Related Questions