I have this piece of code.I am trying to close the div,when clicked outside the Div,I have searched through this forum but can not find a solution -Here is a fiddle- Demo
$('#hideshow1').on("click", function() {
var text = $(this).val();
$("#req").toggle();
});
$(window).on("click keydown", function(e) {
//e.preventDefault() /*For the Esc Key*/
if (e.keyCode === 27 || !$(e.target).is(function() {return $("#req, #hideshow1")})) {
$("#req").hide()
}
}).focus()