开发者

return the element from a 'a' tag?

开发者 https://www.devze.com 2023-02-07 19:01 出处:网络
why does this not return the element? it returns the href attribute on the tag var tst = document.body.appendChild(document.createEl开发者_C百科ement(\'a\'));

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

var tst = document.body.appendChild(document.createEl开发者_C百科ement('a'));
tst.setAttribute('href', 'http://www.test.com');
alert(tst);


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消