这个 AppendChild 调用有什么问题吗?
我正在尝试执行此简单的 AppendChild,调用没有成功:
//Create Video and Apply
function makeVid(src,wW,hH,Ref){
var NewSrc= SrcCollect[Ref];
var ambVid= document.createElement("VIDEO");
ambVid.setAttribute("width",wW);
ambVid.setAttribute("height",hH);
ambVid.setAttribute("src",src);
ambVid.setAttribute("controls","controls");
ambVid.className="ambiVidElement";
ambVid.id="ambiVidElement"+Ref;
var holder = document.getElementById("ambi_vid_wrapper"+Ref);
holder.appendChild(ambVid);
}
它不会产生错误,即使我使用 try{} 捕获错误,也没有错误,但我创建并想要附加的元素没有出现在页面上...
i am trying to do this simple AppendChild, Call with no success:
//Create Video and Apply
function makeVid(src,wW,hH,Ref){
var NewSrc= SrcCollect[Ref];
var ambVid= document.createElement("VIDEO");
ambVid.setAttribute("width",wW);
ambVid.setAttribute("height",hH);
ambVid.setAttribute("src",src);
ambVid.setAttribute("controls","controls");
ambVid.className="ambiVidElement";
ambVid.id="ambiVidElement"+Ref;
var holder = document.getElementById("ambi_vid_wrapper"+Ref);
holder.appendChild(ambVid);
}
It produces no errors, even if i use try{} to catch the error, there is none, but the element i created and want to append does not appear on the page...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
很奇怪没有错误,你检查过浏览器的 JavaScript 控制台吗?使用调试器进行过操作吗?
下面是一些建议(更改了标记有
*
的行):除了上述内容之外,我还会仔细检查
getElementById
调用是否返回您期望的返回值。将此作为 CW 答案,因为它实际上只是一系列调试建议。
It's very odd there are no errors, have you checked your browser's JavaScript console? Walked through with a debugger?
A few suggestions below (changed lines flagged with
*
):Aside from the above, I'd double-check that the
getElementById
call is returning what you expect it to return.Making this a CW answer because it's really more just a series of debugging suggestions.