I wanted to change the color of a table cell depending on the value entered by the user. For example A = green, B = blue, C = black, I was able to make the code change the color of the table, but I can not do the user changes the color.
[data-color="1"],
[data-color="2"] {
background-color: gray;
}
[data-color="3"],
[data-color="4"] {
background-color: yellow;
}
[data-color="5"] {
background-color: red;
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Trabalhando com seletores de atributos</title>
<link rel="stylesheet" href="reset.css">
<link rel="stylesheet" href="color.css">
</head>
<body>
<table>
<thead>
<tr>
<th>Nome</th>
<th>Idade</th>
</tr>
</thead>
<tbody>
<tr data-color="1">
<td>Marco Bruno</td>
<td>1</td>
</tr>
<tr data-color="3">
<td>Antonio Silva</td>
<td>2</td>
</tr>
<tr data-color="3">
<td>Ricardo Souza</td>
<td>3</td>
</tr>
<tr data-color="4">
<td>Paulo Cesar</td>
<td>4</td>
</tr>
<tr data-color="5">
<td>Cesar Oliveira</td>
<td>5</td>
</tr>
</tbody>
</table>
</body>
</html>