我對編碼非常陌生,一個月前我開始參加編程課,最近我們分配了我們的第一個項目。我試圖讓我的JavaScript代碼到我的index.html。到目前爲止,我有這在我的html頁面:初學JavaScript到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頁面,讓我我能夠顯示項目和他們的價格。我似乎無法弄清楚我做錯了什麼。感謝您的時間,任何幫助!
使用jQuery而不是 – Gagantous
複製https://stackoverflow.com/questions/15581059/how-to-add-text-to-an-existing- div-with-jquery – Gagantous
[如何用jQuery將文本添加到現有div](https://stackoverflow.com/questions/15581059/how-to-add-text-to-an-existing-div- with-jquery) –