To ensure proper functionality, it is crucial for your backdrop to have a z-index higher than the content it is meant to cover, yet lower than the box you are working with (such as a dropdown, popup, or modal).
If needed, consider adding a backdrop during the show/shown event:
$('<div class="dropdown-backdrop"/>')
.insertBefore('.yourPopupBox')
.click(function () {
//hide the popup box here
//$(".yourPopupBox").hide();
});
Remember to remove the backdrop in the hidden event:
var backdrop = $(".yourPopupBox").parent().find('.dropdown-backdrop');
if (backdrop) {
backdrop.remove();
}
You can style the backdrop using CSS like this:
.dropdown-backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
//background-color: rgba(0,0,0,0.7);
z-index: 990;
}