문제

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