JSFiddle - React, Tailwind, and code Playground

by lottikarotti

HTML

<form>
  <p>
    <input type="radio" name="auswahl" value="ja">ja<br>
    <input type="radio" name="auswahl" value="nein">nein<br>
  </p>
</form>

JavaScript

$('input').on('change', function() {
    if ( $(this).val() === 'nein' && $(this).closest('p').find('textarea').length == 0 ) {
      $(this).closest('p').append('<textarea>');
    } else {
      $(this).closest('p').find('textarea').remove();
    }
  });