title: Jquery: Change input type from button to submit
body: <p>I have an animated search form as below.</p>
  
  <pre><code>&lt;form role="search" method="get" id="searchform" action="&lt;?php echo home_url('/'); ?&gt;"&gt;
  
  &lt;div id="searchtext"&gt;
      &lt;input type="text" value="" size="25" name="s" id="s" placeholder="&lt;?php esc_attr_e('Search', 'reverie'); ?&gt;"&gt;
  &lt;/div&gt;
  
  &lt;div id="submitsearch"&gt;
      &lt;input type="button" id="searchsubmit" value="" class="button postfix"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>jQuery("#submitsearch").click(function () {
     jQuery("#searchtext").animate({width:'toggle'},500);
        jQuery(this).toggleClass("closed");
  }); 
  </code></pre>
  
  <p>When the search button is first clicked, it toggles out the text area where a user can type in what they want to search. When they click the search button again however, it should submit the search form (i.e. the input type should change from button to submit). </p>
  
  <p>I've read a few posts on SO already, however these are from a few years ago &amp; I'm not sure if they are still relevant. Is it not possible to change an input's type?</p>