Possible Duplicate:
JavaScript setAttribute vs .attribute=
javascript dom, how to handle "special properties" as versus attributes?
Many times, in forums or places such as Usenet I have been told by some (when criticizing my code) that instead of saying, for example var link = a.href
I should use var link = a.getAttribute('href');
instead. And use its complementary setAttribute() when wanting to assign.
They say it is the correct way to do it, that I am wrong, blah blah blah... I don’t normally pay any attention to those. And when I ask why nobody gives a real answer.
Now I am curious about in which cases it would be more suitable to use one or another.
In what cases would be more suitable to say var link = a.getAttribute('href');
instead of var link = a.href
?
And in what cases shoulw I use setAttribute() to assign instead of assigning a value to a member directly by its identifier? i.e: `a.href = 'someURL';