[英]my javascript file will not link to my index.html file and i see nothing wrong with it. What is wrong with it?
here is my index= https://github.com/25garcial/calculator/blob/main/index.html这是我的索引= https://github.com/25garcial/calculator/blob/main/index.html
here is my JavaScript= https://github.com/25garcial/calculator/blob/main/script.js这是我的 JavaScript= https://github.com/25garcial/calculator/blob/main/script.js
I don't know what is wrong with the code and i have asked my teacher and he does not know either.我不知道代码有什么问题,我问过我的老师,他也不知道。
Replace script tag in your index file with this:将索引文件中的脚本标记替换为:
<script src="script.js"></script> <script src="script.js"></script>
At the bottom of the body tag in index.html file link your Javascript file with a script tag:在 index.html 文件 body 标签的底部,使用脚本标签链接您的 Javascript 文件:
<script src="./yourfilename.js"></script>
To link your script try using:要链接您的脚本,请尝试使用:
<script src="script.js"></script>
For more informations see: https://www.w3schools.com/tags/att_script_src.asp有关详细信息,请参阅: https://www.w3schools.com/tags/att_script_src.asp
Also note: You can use the defer
attibute if you want your script to load after the HTML parsing and loading rather than putting it at the end of your body.另请注意:如果您希望脚本在 HTML 解析和加载之后加载而不是将其放在主体的末尾,则可以使用defer
属性。
<script src="script.js" defer></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.