document.getElementByID外部还是内联? [英] document.getElementByID external or inline?
问题描述
我一直在尝试使用 document.getElementByID
从外部JS文件中的HTML文件中提取信息,而且似乎不起作用。如果它与HTML文件是内联的或者可以在外部JS文件上正常工作,那么 document.getElementByID
是否有效?由于其他功能正常,JS文件正确地被调用。
document.getElementByID只能与HTML文件一致使用
否。
可以在外部JS文件上正常工作吗?
是的。
在DOM准备就绪之前,您可能会调用 document.getElementById()
。
I have been trying to use the document.getElementByID
to pull information from an HTML file from an external JS file and it does not seem to be working. Does the document.getElementByID
only work if it is inline with the HTML file or can it work properly on an external JS file? The JS file is called upon within the HTML document properly because other functions are working.
Does the document.getElementByID only work if it is inline with the HTML file
No.
can it work properly on an external JS file?
Yes.
You're probably calling document.getElementById()
before the DOM is ready.
这篇关于document.getElementByID外部还是内联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!