Hi I was wondering if there is another tag that would act like a <td> element, the other times I tried to use something like a <to> or <div> it would appear outside of the table.
When I tried to use the <th> whatever was inside it disappeared.
Sorry here is the fiddle, Iām trying to make a periodic table with atomic numbers at the bottom. But I need to skip the box where the elements at the bottom are supposed to be, and I tried using if loops but it just led to a whole lot more complications. I decided the best way was to look for a tag that could contain. 57-81 and 75-(Iām not quite sure) so the for loop,would not include it and therefore not put a number on them.
Thatās quite a word. āadaptā might be the one weāre reaching for. Thereās nothing to incorporate but the whole. Study it and learn from it by asking questions.
Sorry for not replying earlier ( I live in Phil ), basically I just need guidance whether I should use javascript if () or if I should try to put the two boxes in a different tag so it wonāt be affected by the for loop.
The value assigned is a node list, and should not be inside a loop.
Serially it is difficult to sketch out this table given the constraints. Programatically we can break out some slices, and define output components by these. Weāre in the pragmatic zone, now, and have to work with what we know⦠18 groups, 7 periods,
The number one problem I spot in this code is all the var keywords. This indicates to me some issues with understanding scope. But we should first address the elephant in the room, x.
Assumes x exists when the conditional is evaluated, which no evidence of such has come forward.
> for(; x<121; ) {
}
x Uncaught ReferenceError: x is not defined
This node list should be defined before the loop, and since i is defined before the loop, like x, it should not have a var in the loop. str can be declared also.
If you want to make it simpler, overall,
var td = document.getElementsByTagName("td");
var str;
for(var x = 3, i = 2; x < 121; x++) {
str = "<br><small>";
str += x;
str += "</small>";
i = x - 1;
td[i].innerHTML += str;
}