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

有帮助吗?

解决方案

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!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top