-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday17.html
More file actions
54 lines (52 loc) · 1.61 KB
/
Copy pathday17.html
File metadata and controls
54 lines (52 loc) · 1.61 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<style>
#mydiv{
width: 200px;
height: 200px;
border-radius: 20px;
background-color: cornflowerblue;
text-align: center;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
#circle{
width: 200px;
height: 200px;
border-radius: 200px;
background-color: aqua;
text-align: center;
margin: 30px;
padding: 20px;
}
</style>
</head>
<body>
<div id="mydiv"><br><br>
<button onclick="background()">Click here</button>
</div>
<div id="circle"><br><br>
<button onclick="bg()">Click here</button>
</div>
<script>
function background(){
var r = Math.floor(Math.random()*255)
var g = Math.floor(Math.random()*255)
var b = Math.floor(Math.random()*255)
var mycolor="rgb("+r+","+g+","+b+")"
document.querySelector("#mydiv").style.background=mycolor;
console.log(mycolor)
//we can also use document.getElemtById
//document.body.style.background=mycolor;
}
function bg(){
var a = Math.floor(Math.random()*255)
var c = Math.floor(Math.random()*255)
var d = Math.floor(Math.random()*255)
var mycolor1="rgb("+a+","+c+","+d+")"
document.querySelector("#circle").style.background=mycolor1;
}
</script>
</body>
</html>