How to optimize this functions? Can I make one function for all operations?
$('#b-hat1').click(function() {
$('#hat3').hide();
$('#hat2').hide();
$('#hat1').show();
});
$('#b-hat2').click(function() {
$('#hat3').hide();
$('#hat2').show();
$('#hat1').hide();
});
$('#b-hat3').click(function() {
$('#hat3').show();
$('#hat2').hide();
$('#hat1').hide();
});
#b-hatXrelate to the#hatXelements