Question

In AUI, what is the difference between

node.attr("id")

and

node.getAttribute("id")

where node is an object of type Node.

The documentation on getAttribute says "Allows getting attributes on DOM nodes, normalizing in some cases." but I don't understand what normalizing means, and in what case it is applied.

Thanks, Alain

Était-ce utile?

La solution

node.attr could be both getter and setter.

If you pass second argument to attr, it will be set as value of the attribute (the first argument).

node.getAttribute is only getter.

node.getAttribute normalizes the value for IE and especially for IE < 8. Without falling in many details, this means you may pass w3c standard attribute and it will work on all browsers.

Hope that helps!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top