-1
我的delivInfo元素值未定義。 ids匹配html文件,但我得到一個空白輸出。有點失落了。JavaScript中的/ In循環
編輯:https://plnkr.co/edit/tTQVvr8MxBsAkzhHxRlz?p=catalogue 的HTML代碼
"use strict"; // interpret document contents in JavaScript strict mode
var delivInfo = {};
var foodInfo = {};
var delivSummary = document.getElementById("deliverTo");
var foodSummary = document.getElementById("order");
function processDeliveryInfo() {
\t var prop;
\t delivInfo.name = document.getElementById("nameinput").value;
\t delivInfo.addr = document.getElementById("addrinput").value;
\t delivInfo.city = document.getElementById("cityinput").value;
\t delivInfo.email = document.getElementById("emailinput").value;
\t delivInfo.phone = document.getElementById("phoneinput").value;
\t
\t
\t
\t for (prop in delivInfo) {
\t \t delivSummary.innerHTML += "<p>" + delivInfo[prop] + "<p>";
\t }
}
function previewOrder() {
\t processDeliveryInfo();
\t document.getElementById("previewblock").style.display = "block";
}
你能張貼的HTML代碼中https://plnkr.co/和更新問題 – user93
發佈你的HTML代碼也 –
我試圖複製,http://jsbin.com/hucaxoboti/edit?html ,JS,輸出,JS很好,檢查你的HTML。另外,你在哪裏調用函數? – mand