JSFiddle - React, Tailwind, and code Playground

by Timmy Willison

HTML

<form id="form1" action="" method="post">
    <label><input type="radio" name="test" value="1"/> Test 1</label>
    <label><input type="radio" name="test" value="2"/> Test 2</label>
    <br/><br/>
    Value: <span id="val">?</span>
</form>

JavaScript

$('input[name=test]').change(function() {
  $('#val').html($('#form1 input:radio:checked').val());
});