Well, there are lots of solution for this kinds of problems at here. But, my problem is I am not allowed to edit existing functionality. The existing functionality is:
$('body').on('click', '.parent.normal', function () {
// code for Expanding a div
});
and
$('body').on('click', '.parent.expand', function () {
// code for Closing expanded div
});
What I can do is defining another click
function for clicking outside of the expanded div which will call the existing click event for closing expanded div. To do that, I have written this:
if($('.parent.expand').length > 0) {
$('div:not(".parent.normal, .expanded-content, .expanded-content > div")').click(function () {
$('.parent.expand').click();
});
}
Which is not working actually. How can I make it working?