0
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Pergunta</title>
<style>
.carinha{
width: 50px;
height: 50px;
}
</style>
</head>
<body>
<p>1. Como você está se sentindo essa semana?</p>
<img class="carinha" id="feliz" src="https://i.imgur.com/wGe2gWl.png">
<input name="input" value="normal" id="input1" type="radio" onclick="change1()">
<img class="carinha" id="normal" src="https://i.imgur.com/KDrepED.png">
<input name="input" value="normal" id="input2" type="radio" onclick="change2()">
<img class="carinha" id="triste" src="https://i.imgur.com/2Zdok8l.png">
<input name="input" value="normal" id="input3" type="radio" onclick="change3()">
</body>
<script>
function change1(){
var image = document.querySelector("#feliz")
image.src = "https://i.imgur.com/KL66BbQ.png"
}
function change2(){
var image = document.querySelector("#normal")
image.src = "https://i.imgur.com/3G2HVoJ.png"
}
function change3(){
var image = document.querySelector("#triste")
image.src = "https://i.imgur.com/w9G6PAW.png"
}
</script>
</html>
In this code it is possible to make the three little guys look colorful but I wanted it to be one at a time.
How do I make the little faces return to their original state after clicking on another input?
can put another function by assigning the original images to the
img
and call this function withinchange1, change2 e change3
before assigning the new image– vik