admin管理员组文章数量:1418618
First of all: I'm not much schooled with javascript. So have a problem with the appendChild method. That's my code:
var wrapper = document.getElementsByClassName('innerWrap');
var post = document.createElement('input');
post.style.position = "absolute";
post.style.top = "100px";
document.wrapper.appendChild(post);
Why doesn't it work?
Thanks in advance!
First of all: I'm not much schooled with javascript. So have a problem with the appendChild method. That's my code:
var wrapper = document.getElementsByClassName('innerWrap');
var post = document.createElement('input');
post.style.position = "absolute";
post.style.top = "100px";
document.wrapper.appendChild(post);
Why doesn't it work?
Thanks in advance!
Share Improve this question asked May 9, 2012 at 13:04 Patrick LenzPatrick Lenz 872 silver badges8 bronze badges 1- can you try wrapper.appendChild(post); ? – David K Commented May 9, 2012 at 13:05
2 Answers
Reset to default 6getElementsByClassName
returns an NodeList, not a Node
So you could try var wrapper = document.getElementsByClassName('innerWrap')[0];
Have you tried
wrapper.appendChild(post);
instead of
document.wrapper.appendChild(post);
?
本文标签: javascriptappendChild does not workStack Overflow
版权声明:本文标题:javascript - appendChild does not work - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745295881a2652074.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论