title: Show / hide div on page load depending on radio button value - Jquery and Ruby on Rails Simple Form
body: <p>Using Jquery with Ruby on Rails and the Simple Form Gem I can successfully show / hide a div on changing a radio button, however despite numerous attempts I can't get this to work on page load - divs are always showing, whether the radio button is true or false. Any help would be great thanks.</p>
  
  <pre><code>jQuery(document).ready(function() {
    jQuery('[name="user[nurse_attributes][qualified]"]').on('change', function() {
      if (jQuery(this).val() == 'true' ) {
        jQuery('#denied-quote-one').hide();
      } else {
        jQuery('#denied-quote-one').show();
     }
    });
  });
  </code></pre>
  
  <p>UPDATE - HTML OUTPUT OF RADIO BUTTONS:</p>
  
  <pre><code>&lt;div class="form-group radio_buttons optional user_nurse_qualified"&gt;
     &lt;input type="hidden" name="user[nurse_attributes][qualified]" value=""&gt;
       &lt;span class="radio"&gt;
          &lt;label for="user_nurse_attributes_qualified_true"&gt;
              &lt;input class="radio_buttons optional" type="radio" value="true" checked="checked" name="user[nurse_attributes][qualified]" id="user_nurse_attributes_qualified_true"&gt;Yes
          &lt;/label&gt;
        &lt;/span&gt;
        &lt;span class="radio"&gt;
          &lt;label for="user_nurse_attributes_qualified_false"&gt;
             &lt;input class="radio_buttons optional" readonly="readonly" type="radio" value="false" name="user[nurse_attributes][qualified]" id="user_nurse_attributes_qualified_false"&gt;No
          &lt;/label&gt;
         &lt;/span&gt;
     &lt;/div&gt;
  
    &lt;div id="denied-quote-one" style="display: block;"&gt;
      &lt;p class="p-red"&gt;Unfortunately we cannot give you a quote if your answer to this question is no. You will not be able to move forward.
      &lt;/p&gt;
    &lt;/div&gt;
  </code></pre>