title: How to trigger onchange when the page load
body: <p>I want to trigger on change event when the page load I tried to do <code>$("#formtype").change();</code> but it doesn't work</p>
  
  <pre><code>&lt;div class="form-group"&gt;
    &lt;select name="form" id="formtype" class="form-control"&gt;
      &lt;option value="A"&gt;Form A&lt;/option&gt;
      &lt;option value="B"&gt;Form b&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;script type="text/javascript" src="http://code.jquery.com/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
    $('#formtype').on('change', function () {
      //  alert( this.value ); // or $(this).val()
      if(this.value == "A") {
        $('#form1').show();
        $('#form2').hide();
      } else {
        $('#form1').hide();
        $('#form2').show();
      }
    }); 
  &lt;/script&gt;
  </code></pre>