So I am trying to make like an OS in javascript and yes, I know it would most likely be in HTML but I am working on something, so I had some trouble with it, especially with this simple little itty bitty code, I tried everything with and without and came with two errors. One was the one I put in the title and the second one was without using length and just putting a number, I put 1 in to see what happens. for the second error, it is the same one as this error except without "length" it has "1" or another number I put into it. I also looked through stack overflow and found nothing.
Here is my Code:
var i;
var c = document.getElementsByClassName("app-slot").children;
for (i = 0; i < c.length; i++){
if (c[i].tagName != "img"){
c[i].style.display = "none";
}
}
Can anyone help me tell me what could be wrong with this...my main purpose is to detect if the top element with the class name "app-slot" and see if it has an "img" tag children. I know it works with id's not not any other, I am completely stuck on this. This is different than the duplicated one that has been marked because it uses the children property and just changing it to "querySelectorAll" while keeping the children property does not change a thing, and does not give me an example that I wanted either in one of the answers.