Jump to content

accessing element attributes


skaterdav85

Recommended Posts

The difference is that getAttribute can access any attribute with any name, while using "." can only access the "attributes" that were set as object properties in the HTML DOM specification.In XML, for example, you won't be allowed to access attributes with "." because there are no properties assigned to them.A good example of the difference between an attribute and a property can be seen in the Anchor object: http://w3schools.com/jsref/dom_obj_anchor.aspIf you use anchor.getAttribute("href") it may return something like "page.html" while if you use anchor.href it will return "http://mysite.com/page.html"

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...