clarkk
clarkk

Reputation: 27723

return the element from a 'a' tag?

why does this not return the element? it returns the href attribute on the tag

var tst = document.body.appendChild(document.createElement('a'));
tst.setAttribute('href', 'http://www.test.com');
alert(tst);

Upvotes: 0

Views: 63

Answers (1)

meder omuraliev
meder omuraliev

Reputation: 186662

It does return an element..... .nodeType is 1 and .nodeName is A if you actually test it.

Anchor elements' toString method probably just return the url for certain DOM implementations.

Upvotes: 0

Related Questions