<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Exercise 32 event</title>
<style>
.pet {
width: 70px;
height: 70px;
margin: 20px 60px;
border-radius: 12ex;
background-color: lightpink;
border-style: dashed;
font-size: 22px;
}
#c6 {
height: 300px;
width: 600px;
}
</style>
</head>
<body>
<div id="c6">
<h1>Exercise 32 Events</h1>
<button id="red" class="pet">red</button>
<button id="blue" class="pet">Blue</button>
<button id="purple" class="pet">Purple</button>
</div>
<script>
const btnRed = document.getElementById('red');
const btnblue = document.getElementById('blue');
const btnPur = document.getElementById('purple');
let divC6 = document.querySelector('c6');
function changeColor(name) {
return c6.style.backgroundColor = name;
//document.body.style.backgroundColor = name;
}
btnRed.onclick = ()=> {changeColor('red');}
btnblue.onclick = ()=> {
changeColor('blue');
}
btnPur.onclick = ()=> {
changeColor('purple');
}
</script>
</body>
</html>
Rute Bezerra de Menezes Gondim
No comments:
Post a Comment