BN83 BN83 - 1 year ago 87
HTML Question

Form in popup, disabling child click to close blocking checkbox

I have a popup window that has a form in it and to stop the popped up div clicks from closing the window I've used:

$(".popup").click(function () {
$(".popup").css("display", "none");
}).children().click(function(e) {
return false;

However this works perfectly except with checkboxes whereby it disables checking them.

Is there any way around this?

popup is an overlay, then popupInner holds the form.

Answer Source

Try replacing your code with this:

$(".popup").click(function(e) {
    if ( == this) $(this).hide();

It would hide the popup only if clicked on the element with class popup and not its children, while it should also keep the functionality of the children.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download