Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display Search and Hide it on anywhere click
// Header Search
$('.search a').on('click', function(event){
event.preventDefault();
var search = $(this).attr('href');
$(search).css('right', '0');
});
// Hide search on document click
$(document).mouseup(function(e){
var container = $('#search');
if (!container.is(e.target) && container.has(e.target).length === 0){
container.removeAttr('style');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment