$("#searchbox").hide(); // Hide by default$("button").click(function() {
$('#searchbox').hide();$('.div-triggering-searchbox-hiding').click(function(){ $('#searchbox').hide();}$('#button-triggering-searchbox-showing').click(function(){ $('#searchbox').show();}
$("#searchbox").hide(); // Hide by default$("button").click(function() { $("#searchbox").toggle();});
#searchbox { display: none; }
$("button").click(function() { $("#searchbox").toggle();});
<html class="no-js"> <!-- needed for modernizr to initialize. This is removed as soon as it does init -->
#searchbox { display: none; }.no-js #searchbox { display: block }
I'm doing something like this:
My question is how to display the #searchbox when that element is clicked and hide it again when another div is clicked
JS:
By setting the default in CSS you can guarantee you won't see it then have it flash away.
But if you're loading up modernizr in the head very early you could do this:
You shouldn't see the flash unless you have a reeeaally slow connection.