Javascript code website

·


// Create the body element
const body = document.createElement(‘body’);

// Create the main container
const mainContainer = document.createElement(‘div’);
mainContainer.classList.add(‘main-container’);
body.appendChild(mainContainer);

// Create the header
const header = document.createElement(‘header’);
header.classList.add(‘header’);
mainContainer.appendChild(header);

// Create the navbar
const navBar = document.createElement(‘nav’);
navBar.setAttribute(‘id’, ‘navbar’);
header.appendChild(navBar);

// Create the navbar links
const homeLink = document.createElement(‘a’);
homeLink.setAttribute(‘href’, ‘/home’);
homeLink.textContent = ‘Home’;
navBar.appendChild(homeLink);

const aboutLink = document.createElement(‘a’);
aboutLink.setAttribute(‘href’, ‘/about’);
aboutLink.textContent = ‘About’;
navBar.appendChild(aboutLink);

const contactLink = document.createElement(‘a’);
contactLink.setAttribute(‘href’, ‘/

Leave a comment

Get updates

From art exploration to the latest archeological findings, all here in our weekly newsletter.

Subscribe

Design a site like this with WordPress.com
Get started