Finished tool

This commit is contained in:
Jonathan Branan 2024-08-27 22:25:20 -05:00
parent 9f3ebf9afb
commit c44678e7ab
2 changed files with 18 additions and 4 deletions

8
a.html
View File

@ -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
View File

@ -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;
}