-1

I want to create a div inside a div. I want to create a div with a class of videos, inside the videos div. But it seems to not work.



    var div = document.createElement("div");
    div.class = "video";
    videosDiv.appendChild(div)const videosDiv = document.getElementById("videos");


    var div = document.createElement("div");
    div.class = "video";
    videosDiv.appendChild(div)```

1 Answers1

-3

Use const collection = document.getElementsByClassName("videos"); If you are filtering div elements by class videos and iterate the collection and append child with each element.

Shoaib
  • 25
  • 1