Hello everybody! There is a pop-up form (click on the button - the form appears on the page), but when you close it (click on the cross), the page reloads. How can I fix this?

$(document).ready(function() { $(".show_popup").click(function() { $("#cooperation-form").appendTo('body').toggle(); $("#all").css({ "opacity": 0.5, "background": "black", "z-index": 5 }); $("#cooperation-form").css("z-index", 10); }); $(".close-form").click(function(event) { $("#cooperation-form").hide(); }); }); 
  • Return false or event.preventDefault. Or put the href attribute in #. - u_mulder
  • $(document).ready(function() { $(".show_popup").click(function(){ $("#cooperation-form").appendTo('body').toggle(); $("#all").css({"opacity":0.5,"background":"black", "z-index":5}); $("#cooperation-form").css("z-index",10); }); $(".close-form").click(function (event){ $("#cooperation-form").hide(); event.preventDefault(); }); }); show_popup is the button on which the form is called. all is a div to the whole page, right after the body . After the method you suggested, the page stopped reloading at closing, but the dimming is active. How to fix it? - prolina
  • Please edit your question and paste this code into it. - u_mulder
  • And also realize that when the form appears, the # all div also appears, you also have to do something with it when you close the form. - u_mulder

0