To close or do something when users clicks outside of some element following few lines of code can be helpful.
$(document).click(function(event) { if ($(event.target).parents().index($('#first_wrapper')) == -1 && $(event.target).parents().index($('.second_wrapper')) == -1) { // Run something } });
Leave a Reply
You must be logged in to post a comment.