JSFiddle - React, Tailwind, and code Playground
HTML
<div class="choice">
<input id="choice_1" type="radio" name="choice" value="choice_1" />
<label for="choice_1">Chicago</label>
</div>
<div class="choice">
<input id="choice_2" type="radio" name="choice" value="choice_2" />
<label for="choice_2">Los Angeles</label>
</div>
<div class="choice">
<input id="choice_3" type="radio" name="choice" value="choice_3" />
<label for="choice_3">San Francisco</label>
</div>
CSS
.choice input {
display: none;
}
.choice {
border: 1px solid gray;
padding: 30px;
margin: 20px;
}
.active {
background-color: yellow;
}
JavaScript
$(document).ready(function() {
var choices = $('.choice');
choices.on('click', function(event) {
var choice = $(event.target);
choice
.find('[name="choice"]')
.prop('checked', true)
.trigger('change');
});
var inputs = $('.choice input');
inputs.on('change', function(event) {
var input = $(event.target);
var choice = $(this).closest('.choice');
$('.choice.active').removeClass('active');
choice.addClass('active');
});
});