-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