I have a modal window that needs to be closed, obviously. I've created this piece of code that works okay. But is there a way to optimize it?
// close the modal window
$('.modal-close').click(function(e) {
$('#modal').hide();
$('#modal-overlay').hide();
e.preventDefault();
});
$(document).keydown(function(e) {
if (e.keyCode == 27) { // if Esc key is pressed
$('#modal').hide();
$('#modal-overlay').hide();
}
if (e.keyCode == 9) { // cancel the Tab key
return false;
}
});