forked from valfragier16/JavaScript-DOM
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathmyScript_1.js
More file actions
42 lines (31 loc) · 1.13 KB
/
myScript_1.js
File metadata and controls
42 lines (31 loc) · 1.13 KB
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
36
37
38
39
40
const msgBothPars = "We are coders!";
const msgFirstPar = "Developers for life!";
//Insert text to both paragraphs
let bothPars = document.querySelectorAll(".pars");
for (let i = 0; i < bothPars.length; i++) {
const thisPars = bothPars[i];
thisPars.innerText = msgBothPars;
};
//Change text content & font size of first paragraph
let parFirst = document.getElementById("parOne");
parOne.innerText = msgFirstPar;
parOne.style.fontSize = "40px";
//Assign image to variable
let imageHtml = `
<img id="image" class="divTechImg" src="lib/images/diversetech.jpeg" alt="drawing of diverse people in tech"></img>
`;
//Place image in body of HTML
let bodyTag = document.querySelector('body');
bodyTag.innerHTML += imageHtml;
//Change text color in body to purple
bodyTag.style.color = "purple";
//Create functionality to hide/display image with button
function buttonAction() {
const targetImage = document.querySelector(".divTechImg");
const curStatus = targetImage.style.visibility;
if(curStatus == "hidden"){
targetImage.style.visibility = "visible";
} else {
targetImage.style.visibility = "hidden";
}
}