appendChild
appendChild
에 대해 배웠고 지금까지이 코드를 생각해 냈습니다 :
var blah = "Blah!";
var t = document.createElement("table"),
tb = document.createElement("tbody"),
tr = document.createElement("tr"),
td = document.createElement("td");
t.style.width = "100%";
t.style.borderCollapse = 'collapse';
td.appendChild(document.createTextNode(blah));
// note the reverse order of adding child
tr.appendChild(td);
tb.appendChild(tr);
t.appendChild(tb);
document.getElementById("theBlah").appendChild(t);
<div id="theBlah">d</div>
그러나 저에게 Uncaught TypeError: Cannot call method 'appendChild' of null
을 말하는 오류가 있습니다. 내가 뭘 잘못하고 있죠?
* theBlah * 아래에 스크립트를 배치 할 수 있으며 * onload * 수신기 없이도 작동합니다. – RobG