Thanks to Jquery there is very simple way doing this. jQuery has introduce a function call “stopPropagation()” to prevent executing parent events on child elements. We was developing full-screen search popup and we needed it to close when they click on the background. it was simple but search form is child of full-screen div so whenever they click on search field it gets close.
then thanks to this solution it works!
Here is the code
w3school tute : http://www.w3schools.com/jquery/event_stoppropagation.asp