任何人都可以幫助我,告訴我代碼有什麼問題。 請幫我用這段代碼。我不知道那有什麼問題。 任何人都可以幫助我,告訴我代碼有什麼問題。 請幫我用這段代碼。我不知道那有什麼問題。我在做什麼錯誤的JavaScript?
<!DOCTYPE html>
<html>
<body>
<p id="demo">enter code here</p>
<script>
var all = [
{
"name": "redfruit",
"price": 9.20,
"text2": "Our selection of red fruits and fresh milk<br>No added preservatives or sugars"
},
{
"name": "veggie",
"price": 8.80,
"text2": "Our selection of veggies and fresh milk<br>No added preservatives or sugars"
},
{
"name": "jajko",
"price": 6.90,
"text2": "Our selection of veggies and fresh milk<br>No added preservatives or sugars"
}
];
var i;
for(i=0;i<all.length;i++)
{var moko=all[i];
var extrahtml='\
<li>\
<div class="info">\
<h3>' + moko.name + '</h3>\
<p>' + moko.price.toFixed(2) +' </p>\
<p>' + moko.text2 + '</p>\
'</div>\
</li>\
';
document.getElementById("demo").innerHTML += extrahtml;
}
</script>
</body>
</html>
有什麼錯誤?你能告訴我們HTML頁面是什麼樣子嗎?你想得到什麼? – Edric