title: jQuery - Check current state of radio button and hide div
body: <p><strong>QUESTION:</strong> How would I check the value of a radio button onload and if it is a certain value, perform an action based up on that? Referenced at the end of my code in the <em>if</em> statement.</p>
  
  <p><strong>MORE IN-DEPTH EXPLANATION</strong></p>
  
  <p>So I know the title of this might sound familiar to other questions, but I have a bit more involved and trying to see the best way to approach it. So, in my function <code>homepageDisplayHandleSelection()</code> I hide/show areas based on the selection of radio buttons from within that <code>.homepage_display</code> area. Then, I basically use that same functionality for another group of radio buttons within it called <code>mainImageLinkHandleSelection</code> and then hides/shows areas based on the selection. I can switch between the <code>Static</code> and <code>Slide</code> option just fine, but the initial view (if <code>Slideshow</code> is selected when the page loads) is that it is still showing the secondary radio buttons <code>mainImageLinkHandleSelection</code> and it is not until I click off of the <code>Slideshow</code> option and back to <code>Static</code> that it corrects itself. </p>
  
  <p>So, I attempted to fix this (at the bottom of the example code) by creating a check if the current radio value that is checked is <code>slideshow</code> and if so, I hide a div called <code>main_link</code> (which is also attached to each of the areas around the <code>mainImageLinkHandleSelection</code> divs). I know my question has bunch of parts in it, but I figured if anyone could help, there'd be a genius out there somewhere ;) Thank you very much for any and all help!</p>
  
  <pre><code>jQuery(document).ready(function() {
  
      // Homepage Settings - Homepage Display
      // This function handles the radio clicks.
      function homepageDisplayHandleSelection() {
          var duration = 400;
          jQuery('.homepage_display').hide(duration);
          jQuery('.main_link').hide(duration);
          if (this.value === "slideshow") {
            jQuery('.homepage_display_slides').show(duration);     
          } else if (this.value === "static") {
            jQuery('.homepage_display_static').show(duration);     
          }
      }
  
      // Attach a click handler to the radios
      // and trigger the selected radio
      jQuery('#section-of_homepage_display :radio')
          .click(homepageDisplayHandleSelection)
          .filter(':checked').trigger('click');
  
      // Homepage Settings - Main Link Options
      // This function handles the radio clicks.
      function mainImageLinkHandleSelection() {
          var duration = 400;
          jQuery('.main_link').hide(duration);
          if (this.value === "external_url") {
            jQuery('.main_link_external').show(duration);     
          } else if (this.value === "wp_page") {
            jQuery('.main_link_page').show(duration);     
          }
            else if (this.value === "wp_post") {
            jQuery('.main_link_post').show(duration);     
          }
            else if (this.value === "wp_taxonomy") {
            jQuery('.main_link_category').show(duration);     
          }
      }
  
      // Attach a click handler to the radios
      // and trigger the selected radio
      jQuery("#section-of_main_image_link_option :radio")
          .click(mainImageLinkHandleSelection)
          .filter(":checked").trigger("click");
  
  
    // Make sure main image link option are hidden by default if slideshow option is selected
      if (jQuery('#section-of_homepage_display :radio :checked').val() === 'slideshow') {
        jQuery('.main_link').hide();
      }
  
  });
  </code></pre>