Reputation: 3047
test.php:
<script type="text/javascript" src="test.js"></script>
<body onload="init()">
test.js:
var req;
var isIE;
var completeField;
var completeTable;
var autoRow;
function init() {
completeField = document.getElementById("complete-field");
completeTable = document.createElement("table");
console.log(completeTable);
completeTable.setAttribute("class", "popupBox");
completeTable.setAttribute("style", "display: none");
}
In console, it shows:
<table class="popupBox" style="display: none"></table>
Question:
completeTable.setAttribute
runs after console.log(completeTable);
, how come, it still shows the table attributes?
Upvotes: 0
Views: 32
Reputation: 1664
It is because console.log
takes the state of the actual object when you look into the logged object... Try alert(completeTable.getAttribute("style"))
instead and you will see there is no style yet.
Upvotes: 3