Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
889 B
0
Indexable
Never
// 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);