I am curious if it is possible to change the color of a box when it is clicked.
I am working on coding a "calculator layout" and would like to start with this part
1 2 3
4 5 6
7 8 9
0
This is what I have been working on and struggling with.
$(document).ready(function() {
$("#k1").click(function() {
$("#k1").backgroundcolor = 'red';
});
});
.grid-container {
display: grid;
grid-template-columns: auto auto auto;
gap: 10px;
background-color: #c5c5c5;
padding: 10px;
}
.grid-container>div {
background-color: rgba(255, 255, 255, 0.8);
border: 1px solid black;
text-align: center;
font-size: 30px;
}
.it0 {
grid-column-start: 2;
grid-column-end: 3;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="grid-container">
<div id="k1" class="it1">1</div>
<div id="k2" class="it2">2</div>
<div id="k3" class="it3">3</div>
<div id="k0" class="it0">0</div>
</div>