Finished tool
This commit is contained in:
parent
9f3ebf9afb
commit
c44678e7ab
8
a.html
8
a.html
@ -24,9 +24,9 @@
|
||||
<body>
|
||||
<h3>Color Flipper</h3>
|
||||
<script src="a.js"></script>
|
||||
<button id="green">green</button>
|
||||
<button id="red">red</button>
|
||||
<button id="blue">blue</button>
|
||||
<button >random</button>
|
||||
<button id="green" onclick=setColor('green')>green</button>
|
||||
<button id="red"onclick=setColor('red')> red</button>
|
||||
<button id="blue"onclick=setColor('blue')>blue</button>
|
||||
<button onclick=randomColor()>random</button>
|
||||
</body>
|
||||
</html>
|
14
a.js
14
a.js
@ -0,0 +1,14 @@
|
||||
const body = document.getElementsByTagName("body")[0]
|
||||
|
||||
function setColor(name) {
|
||||
body.style.backgroundColor = name;
|
||||
}
|
||||
|
||||
function randomColor(){
|
||||
const red = Math.round(Math.random() * 255)
|
||||
const green = Math.round(Math.random() * 255)
|
||||
const blue = Math.round(Math.random() * 255)
|
||||
const color = `rgb(${red},${green},${blue})`
|
||||
|
||||
body.style.backgroundColor = color;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user