Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 1
    @Aerovistae - agree with you on this. Added a new answer which is hopefully clearer. Commented Jan 10, 2014 at 12:50
  • 1
    But if you want to affect the innerHTML of the element, you have to use setAttribute... Commented Jan 10, 2014 at 19:05
  • 3
    You mean outterHTML* :) Commented Apr 7, 2014 at 16:39
  • 4
    I found that a.href returns full url, but getAttribute('href') returns exactly what in that attribute (<a href="/help" ...). Commented Feb 9, 2015 at 13:06
  • 2
    This answer is misleading. getAttribute/setAttribute do not deal in literal text. They are just two ways of accessing the same information. Check out my answer below for a complete explanation. Commented Apr 12, 2016 at 19:04