JSFiddle - React, Tailwind, and code Playground

by lindychen

HTML

<form id="contactx" name="contact" action="" method="post" onsubmit="return validate_form('contact')">Select one of the following:
    <br />
    <select name='select-question'>
        <option value="member-request">Become a member</option>
        <option value="question">Send us your questions / comments</option>
    </select>
    <br />Last name:*
    <br />
    <input type="text" name="last-name"></input>
    <br />First name:*
    <br />
    <input type="text" name="first-name"></input>
    <br />Email address:*
    <br />
    <input type="text" name="email"></input>
    <div id="comments" style="display:none">
    <br />Comments/questions:</br>
    <textarea name="questions-field" rows="5" cols="27"></textarea>
</div>
    <br />
    <input type="submit" name="submit" value="Submit"></input>
</form>

JavaScript

$(document).ready(function () {
    $('#contactx select[name="select-question"]').change(function () {
        if ($('#contactx select[name="select-question"] option:selected').val() == 'question') {
            $('#comments').show();
        } else {
            $('#comments').hide();
        }
    });
    });