Skip to content

Commit c8e6845

Browse files
Create a project using Javascript
1 parent 9585ea8 commit c8e6845

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

12_Project/ChangeBodyColor.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Background Change Color</title>
7+
</head>
8+
<body>
9+
<div class="bg-change">
10+
<h1>Change the background color.</h1>
11+
<Button class="btn" id="btn">Change Color</Button>
12+
</div>
13+
</body>
14+
<script>
15+
document.querySelector('#btn').addEventListener('click',function(e){
16+
const randomColor='#'+Math.floor(Math.random()*16777215).toString(16);
17+
document.body.style.backgroundColor=randomColor;
18+
})
19+
</script>
20+
</html>

12_Project/CreateCircle.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Circle Creation Button</title>
7+
<style>
8+
body {
9+
transition: background-color 0.5s ease;
10+
text-align: center;
11+
}
12+
button {
13+
padding: 10px;
14+
font-size: 16px;
15+
cursor: pointer;
16+
}
17+
.circle {
18+
width: 100px;
19+
height: 100px;
20+
border-radius: 50%;
21+
margin: 20px auto;
22+
}
23+
</style>
24+
</head>
25+
<body>
26+
27+
<button id="btn">Create Circle</button>
28+
<div id="circleContainer"></div>
29+
30+
<script>
31+
document.querySelector('#btn').addEventListener('click',function(e){
32+
const circle=document.createElement("div");
33+
circle.className="circle";
34+
circle.style.backgroundColor="blue";
35+
document.getElementById("circleContainer").appendChild(circle);
36+
})
37+
</script>
38+
39+
</body>
40+
</html>

0 commit comments

Comments
 (0)