Append and then Hide

Append and then Hide

If I have some content I want to show but not have within the original document but in the .js file, for example:

$("a#searchButton").click(function() {
  
$(".main").prepend("<div class=\"searchMainCont\"><img id=\"close\" src=\"/images/cross.png\"/><h1>Search</h1><br /><form id=\"searchForm\" name=\"searchForm\" method=\"post\" action=\"\"><input id=\"term\" name=\"term\" type=\"text\" size=\"20\" value=\"Search Term\" onClick=\"this.value=''\" /><input id=\"search\" name=\"search\" type=\"submit\" value=\"Search\" /></form></div><br clear=\"all\" /><br />");
$("a#searchButton").css("display", "none");
});

But then I want to hide that whole div afterwards is this possible?

I tried using display none to the child element of .main and also with img parent but no luck.