JSFiddle - React, Tailwind, and code Playground

by neal_fletcher

HTML

<input type="radio" name="hello" value="male">Male
<br/>
<input type="radio" name="hello" value="female">Female
<br/>
<br/>
<div class="test">Hello</div>

CSS

.thisClass {
    color: red;
}

JavaScript

$(document).ready(function () {
    $('input[name=hello]').on('change', function () {
        var test = $('input[name=hello]:checked').val();
        $('.test').html(test);
        $('.test').attr('data-hook', test);
        if ($('.test').attr('data-hook') == 'female') {
            $('.test').addClass('thisClass');
        } else {
            // do that
        }
    });



});