这应该很简单,但我无法将一个对象的属性复制到另一个对象。
var tableFormatting = {
table: {
style: {
width: "100px",
height: "100px"
},
border: "1px"
}
//similar code for tbody, tr, td
};
var table = document.createElement('table');
for (var p in tableFormatting.table)
table[p] = tableFormatting.table[p];
alert(table.style.width); //shows nothing. can't access it
alert(typeof(table.style.width)); //shows string, so i know it was copied or has a reference
alert(table.border); //shows 1px. this one is copied and accessible
为什么不显示样式属性?