title: How to show or hide div or form element with jquery?
body: <p>I am trying to show or hide fieldset based on the answer selected on YES/NO radio button. I have multiple form elements that has to be shown or hidden based on their corresponding YES/NO radio button. But the code below is not working for me. Could someone help me to correct this problem?</p>
  
  <pre><code>&lt;!-- My Form Element  --&gt;
  
  &lt;form&gt;
  &lt;fieldset id="question"&gt;
    &lt;legend&gt;This is my question&lt;/legend&gt;
    &lt;label for="answerYes"&gt;Yes&lt;/label&gt;
    &lt;input name="answer" class="myradio" type="radio" value="1" /&gt;
    &lt;label for="answerNo"&gt;No&lt;/label&gt;
    &lt;input name="answer" class="myradio" type="radio" value="0" /&gt;
  &lt;/fieldset&gt;
  
  &lt;fieldset class="subQuestion"&gt;
    &lt;legend&gt;This is my question&lt;/legend&gt;
    &lt;label for="answerYes"&gt;Yes&lt;/label&gt;
    &lt;input name="answer" class="subradio" type="radio" value="1" /&gt;
    &lt;label for="answerNo"&gt;No&lt;/label&gt;
    &lt;input name="answer" class="subradio" type="radio" value="0" /&gt;
  &lt;/fieldset&gt;
  
  &lt;/form&gt;
  
  
  // Jquery to show or hide subQuestion
  
  $(document).ready(function(){
    // do your checks of the radio buttons here and show/hide what you want to
    $(".subQuestion").hide();
  
    $(document).on('click', '.myradio' , function() {
           if ($(this.value).length &gt; 0){ 
              $(".subQuestion").show();           
           }
           else {
              $(".subQuestion").hide();           
           }       
      })
  
  });
  </code></pre>