On Aug 27, 11:16 am, William Chang <diehardb...@gmail.com> wrote: > I don't think the attribute is defined by default, after I did some > more testing. I find the value return is not consistent between > Firefox and IE8 (and probably previous versions of Microsoft Internet > Explorer).
First of all, the attr() function has had problems for a long time. Don't use it. Properties and attributes are different things, and jQuery confuses the two in unpredictable ways. Although you are requesting the attribute value, it really returns the property value. Read through the source of attr() and it becomes pretty clear what is happening. The difference you are seeing is due to the (name in elem) check. IE is returning true, causing the property [false] to be returned. FF is returning false, causing getAttribute() to be called, which returns null, which gets "normalized" to undefined. Depending on what type of element you are calling this on, the results may be the same (input, for example), or different (img, for example). It's always best to avoid using attr() because of it's poor implementation. IMO. Matt Kruse --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---