So I want, when "search" is clicked, a little bar comes down from the top of the page with the search form, and a close button. Clicking the bar to the close button slides the popup back above the page. he code is below, however my question is "How can I do this better? It currently seems very messy! Is there a way to not use that hidden div on the page, and have it created just when the function is run on click?"
So it starts with an anchor that triggers a javascript function to topdown the search bar:
<a onClick="toggleSearch()">Search</a>
function toggleSearch() {
$('#searchoverflow').slideToggle('fast')
};
It toggles up and down a hidden div, #searchoverflow (this is what I'd like to get rid of).
<div class="notification" id="searchoverflow">
<a href="javascript:" onClick="toggleSearch()" style="width:100%; position:absolute;height:50px;"></a>
<div style="width:0px"><form style="width:200px" role="search" method="get" id="searchform" action="http://thenozzle.net/"><input type="text" value="" name="s" id="s"><input style="left:5px" type="submit" id="searchsubmit" value="Search"></form></div>
<a href="javascript:" class="notificationclose" onClick="toggleSearch()">CLOSE</a>
</div><!-- searchoverflow -->
he popup div explained: The notification class just styles it, it isn't related. The ID of search overflow is what I'm using in the javascript function, because I have other notifications on the page, and need to make this one specific. The first anchor inside the popup is what I'm using to make the search bar disappear when clicking its body. Below that, the other anchor is just case people don't realize the entire thing will make is hide. The middle div just has the search form in it.
Thanks in advance!
tl;dr I'm trying to simplify the above code in any way possible to it's more semantic, less messy, and I don't have to use that hidden popup div in the html unless necessary.