If you’re wanting to set each cell to have a red background individually on click it would be done like this and will alert after all 5 have been clicked.
$('#one, #two, #three, #four, #five').click( function() {
$(this).toggleClass("redbg");
if($('.redbg').length == 5)
alert('Bingo!');
});
.redbg
{
background: red;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr>
<td id="one">1</td>
<td id="two">2</td>
<td id="three">3</td>
<td id="four">4</td>
<td id="five">5</td>
</tr>
</table>
Also, as T.J. Crowder pointed in the comments below. Starting an ID with a numeric value is invalid for CSS. You can do that with with class identifiers, but not IDs. I’ve changed your IDs in this example.
1
solved How to popup an alert when every cell in a table has been clicked?