This version is old school.
Please find jQuery plugins on npm.
jQuery ClickTrap
jQuery plugin for handling Click Trapping. This plugin allows you to mimic the blur() event on a set of nodes. Useful for complex controls with internal events that need to be reset when clicked outside of the combined area.