I have simple script which make layer on background when popup div is shown.
jQuery(".openForm").click(function() {
jQuery("#popup").show();
jQuery("body").append('<div id="layer"></div>');
});
This works fine but, when I click somewhere it should close popup with this script
jQuery("#layer").click(function() {
jQuery("#popup").hide();
jQuery("#layer").remove();
});
anyway nothink happens, there is no error even.