P粉9589860702023-08-16 21:48:18
You can use the pseudo-class :has()
, but its support in browsers is limited (for example: Mozilla does not support it). You can check the browser support of this selector.
tr:has(input:checked){ background: green; }
<script src="http://cdn.tailwindcss.com"></script> <table> <tr class="flex items-center p-4 space-x-4 border hover:bg-indigo-50"> <td> <input type="radio" name="user" id="{{ user.id }}"> <label for="{{ user.id }}">{{ user.email }}</label> <div>{{ user.name }}</div> </td> </tr> </table>