-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (38 loc) · 1.87 KB
/
app.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const colors =["The Earth is the third planet from the Sun",
"A group of owls is called a parliament",
"The Eiffel Tower in Paris, France, was completed in 1889",
"Honey never spoils; archaeologists have found pots of honey in ancient Egyptian tombs that are over 3,000 years old and still edible",
"The human brain is approximately 75% water",
"The Great Wall of China is over 13,000 miles long",
"The fastest land animal is the cheetah, capable of reaching speeds up to 60-70 miles per hour",
"Bees can see ultraviolet light, which helps them find nectar in flowers",
"Octopuses have three hearts",
"The moon's gravity is about 1/6th of Earth's gravity"]
const btn = document.getElementById('btn');
const color = document.querySelector('.color')
btn . addEventListener("click",function(){
// get randon number between0-3
const randomFacts = getRandomFacts();
document.body.style.backgroundcolor = colors[randomFacts];
color.textContent=colors[randomFacts]
});
function getRandomFacts(){
return Math.floor( Math.random()*colors.length );
}
// Get the form element
const form = document.getElementById('contentForm');
// Get the div where submitted content will be displayed
const submittedContentDiv = document.getElementById('submittedContent');
// Add a submit event listener to the form
form.addEventListener('submit', function (event) {
event.preventDefault(); // Prevent the default form submission
// Get the content from the textarea
const content = document.getElementById('content').value;
// Create a new element to display the submitted content
const contentElement = document.createElement('p');
contentElement.textContent = content;
// Append the content element to the submittedContentDiv
submittedContentDiv.appendChild(contentElement);
// Clear the textarea
document.getElementById('content').value = '';
});