JSFiddle - React, Tailwind, and code Playground
by ysis81
HTML
<div id="PlayerVsComputer" class="checkbox">
<label><input type="checkbox" class="game">
<div class="btn-group" role="group">
<button type="button" class="btn btn-inverse btn-xs">Player</button>
<button type="button" class="btn btn-classic btn-xs">Computer</button>
</div>
</label>
</div>
CSS
.btn-classic {
color: black;
background-color: white;
}
.btn-inverse {
color: white;
background-color: black;
}
JavaScript
// Flip buttons color when mouse is over buttons
//var buttons = $('#PlayerVsComputer .btn').mouseenter(toggle).mouseout(restore);
// Flip buttons color when mouse is over buttons
var buttons = $('#PlayerVsComputer .btn').mouseenter(toggle);
$('#PlayerVsComputer').mouseleave(restore);
function toggle() {
buttons.each(function(index, value) {
$(value).toggleClass('btn-inverse btn-classic');
});
}
function restore() {
buttons.eq(0).removeClass('btn-classic').addClass('btn-inverse');
buttons.eq(1).removeClass('btn-inverse').addClass('btn-classic');
}