MegaSack DRAW - 6pm Christmas Eve - LIVE on our YouTube Channel
Topic starter
I know his is simple stuff but I'm stumped
I've managed to insert a div with a id of 'Id_1'. However it doesn't get my css class of 'pixel'. Why?
divTag = document.createElement("div");
divTag.class = "pixel";
divTag.id = "Id_1"
document.getElementById("aRow").appendChild(divTag);
Posted : 18/10/2020 8:28 pm
Topic starter
divTag.className = “pixel”;
that took years off my life.
Posted : 18/10/2020 8:42 pm
‘class’ is a reserved word, hence it needing to be ‘className’. Same for ‘for’, and is ‘htmlFor’ instead.
Posted : 18/10/2020 8:53 pm
Topic starter
Makes sense. No wonder google was always came up with JS classes.
Much thanks.
Posted : 18/10/2020 9:28 pm

