SnookSurvey Recap: Element Attributes in JavaScript
So, in the first edition of this survey I asked whether people thought they should use element.attribute
or element.getAttribute('attribute')
. In the end, it came out pretty much 50/50 although some people tended to switch depending on the situation since some scenarios present some gotchas.
It took until the 20th comment before someone mentioned the fact that, indeed, element.attribute
is part of a spec. Not even DOM0 but DOM2 HTML. Although, the spec actually recommends against its use.
And for the record, I tend to use element.attribute almost exclusively.
All-in-all, I think that was a fun exercise. Now onto the next challenge...