JSFiddle - React, Tailwind, and code Playground

by MrTest

JavaScript

$('select[name="q2"]').click( function(){
        
        if( $(this).children("option:selected").val() === "yes" ) { 
            console.log("Q2: YES");
            // Show Injury Form = Hide All Near Miss 
            $('.nearmiss').each( function(){ $(this).hide(); });
            $('.injury').each( function(){ $(this).show(); });
            
        } else if ( $(this).children("option:selected").val() === "no" ) { 
            console.log("Q2: NO");
            // Show Near Miss Form = Hide All Injury
            $('.injury').each( function(){ $(this).hide(); });
            $('.nearmiss').each( function(){ $(this).show(); });
        }
    });