我是编码的新手,我一个月前开始上编程课,最近我们被分配了第一个项目。我正在尝试将我的 javascript 代码放入我的 index.html 中。到目前为止,我的 html 页面中有这个:
<script src="/project1/prices.js" type='Javascript/text></script>`
我的 javascript 页面目前有这个:
var price1Name = "Tickets for 18 and under";
var price2Name = "Tickets for 18 and over";
var price3Name = "T-shirt (all sizes)";
var price4Name = "Jackets (all sizes)";
var price1price = "$5.00";
var price2price = "$10.00";
var price3price = "$15.00";
var price4price = "$20.00";
document.write(price1Name);
document.write(price1price);
document.write(price2Name);
document.write(price2price);
document.write(price3Name);
document.write(price3price);
document.write(price4Name);
document.write(price4price);
我要做的就是将这段代码输入到我的 Html 页面中,以便我能够显示商品及其价格。我似乎无法弄清楚我做错了什么。感谢您的宝贵时间,任何事情都有帮助!
最佳答案
看起来你的 script
标签有几个错误
<script src="/project1/prices.js" type="text/javascript"></script>
关于javascript - 初学者 JavaScript 到 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46757641/