Untitled
unknown
plain_text
10 months ago
742 B
2
Indexable
const categoriesElements = document.querySelectorAll('.categories'); // Iterate over each selected element categoriesElements.forEach(categoriesElement => { // Create the div element const newDiv = document.createElement('div'); newDiv.className = 'new-div-class'; // Set any classes for the div if needed // Create the img element const newImg = document.createElement('img'); newImg.src = 'your-image-url.jpg'; // Set the src attribute for the img element newImg.alt = 'Image'; // Set any other attributes or properties for the img if needed // Append the img to the div newDiv.appendChild(newImg); // Append the div to the current categoriesElement categoriesElement.appendChild(newDiv); });
Editor is loading...
Leave a Comment