0
I’m doing a classic old game in HTML, CSS and Javascript, however, I want to know which command I can use to change the image of a javascript button
I know it has something to do with Document.getElementById()
<!DOCTYPE html>
<html>
<head>
<title>TicTacToe</title>
<meta charset="utf-8">
<style type="text/css">
body{
background: #eff2ef;
}
#principal{
}
#principal td tr{
background: white;
margin: 20px;
border: solid;
border-color: black;
padding: 30px;
}
#principal td tr label{
background: white;
}
</style>
<script type="text/javascript">
var fotos = ["images/fundoCinza.jpeg" ," images/fundoX.jpeg " , "images/fundoO.jpeg"];
</script>
</head>
<body>
<div id="tabela" align="center">
<table id="principal">
<tr>
<td>
<button><img src="images/fundoCinza.jpg" width="100" height="100"></button>
</td>
<td>
<button><img src="images/fundoCinza.jpg" width="100" height="100"></button>
</td>
<td>
<button><img src="images/fundoCinza.jpg" width="100" height="100"></button>
</td>
</tr>
<tr>
<td>
<button><img src="images/fundoCinza.jpg" width="100" height="100"></button>
</td>
<td>
<button><img src="images/fundoCinza.jpg" width="100" height="100"></button>
</td>
<td>
<button><img src="images/fundoCinza.jpg" width="100" height="100"></button>
</td>
</tr>
<tr>
<td>
<button><img src="images/fundoCinza.jpg" width="100" height="100"></button>
</td>
<td>
<button><img src="images/fundoCinza.jpg" width="100" height="100"></button>
</td>
<td>
<button><img src="images/fundoCinza.jpg" width="100" height="100"></button>
</td>
</tr>
</div>
</table>
</body>
</html>
I want when I click on some of these buttons, it will change to a second image (which in case will be this gray background with an X in front
You want it to automatically change to the next image in the list sequence, or you want it to change to a specific photo?
– Gustavo Sampaio
For a specific photo
– Vitor Corrêa