odin-dom-exercise/index.js

29 lines
739 B
JavaScript
Raw Permalink Normal View History

2024-01-06 21:22:17 +00:00
const container = document.querySelector('#container');
const content = document.createElement('div');
content.classList.add('content');
content.textContent = 'This is the glorious text-content!';
container.appendChild(content);
2024-01-06 21:22:57 +00:00
const p1 = document.createElement('p');
p1.style.color = "#f00";
p1.textContent = "Hey I'm red!";
const h3 = document.createElement('h3');
h3.style.color = "#00f";
h3.textContent = "I'm a blue h3!";
const div = document.createElement('div');
div.style.cssText = "border: 2px solid #000; background: pink;";
const h1 = document.createElement('h1');
h1.textContent = "I'm in a div!";
const p2 = document.createElement('p');
p2.textContent = "ME TOO!";
div.append(h1, p2);
container.append(p1, h3, div);