Untitled

 avatar
unknown
plain_text
3 years ago
889 B
3
Indexable
// create a container element for the menu
const menuContainer = document.createElement('div');
menuContainer.classList.add('menu-container');

// create the menu items
const menuItems = ['Home', 'About', 'Contact', 'Blog'];

// create the menu using a loop
for (let i = 0; i < menuItems.length; i++) {
  const menuItem = document.createElement('div');
  menuItem.classList.add('menu-item');

  // add a link to the menu item
  const link = document.createElement('a');
  link.href = '#';
  link.textContent = menuItems[i];
  menuItem.appendChild(link);

  // add a modern graphic to the menu item
  const graphic = document.createElement('div');
  graphic.classList.add('menu-item-graphic');
  menuItem.appendChild(graphic);

  // add the menu item to the container
  menuContainer.appendChild(menuItem);
}

// add the menu container to the page
document.body.appendChild(menuContainer);
Editor is loading...