-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanipdom.js
35 lines (27 loc) · 1.19 KB
/
manipdom.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const container = document.querySelector('#container');
const content = document.createElement('div');
content.classList.add('content');
content.textContent = 'This is a glorious text-content!';
container.appendChild(content);
// a <p> with red text that says "Hey I'm red!"
const redtext = document.createElement('p');
redtext.style.color = 'red';
redtext.textContent = "Hey I'm red!";
container.appendChild(redtext);
//an <h3> with blue text that says “I’m a blue h3!”
const blueh3 = document.createElement('h3');
blueh3.style.color = 'blue';
blueh3.textContent = "I'm a blue h3!";
container.appendChild(blueh3);
// a <div> with a black border and pink background color with the following elements inside of it:
const pinkBox = document.createElement('div');
pinkBox.style.cssText = 'background-color: pink; border-style: solid; border-color: black; border-width: 2px';
container.appendChild(pinkBox);
const innerh1 = document.createElement('h1');
innerh1.textContent = "I'm in a div";
pinkBox.appendChild(innerh1);
const meToo = document.createElement('p');
meToo.textContent = "ME TOO!";
pinkBox.appendChild(meToo);
const btn = document.querySelector('#btn');
btn.onclick = () => alert("Hello World");