I am a developer and I know how hard it is to solve difficult issues while programming in case you did not get any help. I have faced this so many times. That's why I started this blog so that I can share problems and solutions with developer community. In case if you face any issue in programming do check my blog once, it will surely save your time.
jQuery Close Modal Window When User Clicks Outside of It
In above picture I explained how to do it. So basic trick is to track click event on entire web page and to check it it's X and Y coordinates are inside the BOX of modal window. If yes then do not close it. But if it's out side of it, close the modal popup. Here is the code for the same.
var rect = $('.modalSelector').getBoundingClientRect();
clientX1 = rect.x
clientX2 = rect.x + rect.width;