1 $('form').submit( function(ev){
2
3 ev.preventDefault();
4
5 //later you decide you want to submit
6 $(this).unbind('submit').submit()
7
8 });
1// preventDefault
2
3<!DOCTYPE html>
4<html>
5<head>
6<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
7<script>
8$(document).ready(function(){
9 $("a").click(function(event){
10 event.preventDefault();
11 });
12});
13</script>
14</head>
15<body>
16
17<a href="https://w3schools.com/">Go to W3Schools.com</a>
18
19<p>The preventDefault() method will prevent the link above from following the URL.</p>
20
21</body>
22//Another example
23</html>
24
25<!DOCTYPE html>
26<html>
27<body>
28
29<a id="myAnchor" href="https://w3schools.com/">Go to W3Schools.com</a>
30
31<p>The preventDefault() method will prevent the link above from following the URL.</p>
32
33<script>
34document.getElementById("myAnchor").addEventListener("click", function(event){
35 event.preventDefault()
36});
37</script>
38
39</body>
40</html>