I have an animated search form as below.
<form role="search" method="get" id="searchform" action="<?php echo home_url('/'); ?>">
<div id="searchtext">
<input type="text" value="" size="25" name="s" id="s" placeholder="<?php esc_attr_e('Search', 'reverie'); ?>">
</div>
<div id="submitsearch">
<input type="button" id="searchsubmit" value="" class="button postfix">
</div>
jQuery("#submitsearch").click(function () {
jQuery("#searchtext").animate({width:'toggle'},500);
jQuery(this).toggleClass("closed");
});
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).
I've read a few posts on SO already, however these are from a few years ago & I'm not sure if they are still relevant. Is it not possible to change an input's type?