Jquery function BEFORE form submission

后端 未结 7 2084
一整个雨季
一整个雨季 2020-12-13 08:25

I am trying to fire a function using Jquery when the form submit button is clicked, but the function needs to fire BEFORE the form is actually submitted.

I am trying

相关标签:
7条回答
  • 2020-12-13 09:00

    You can use some div or span instead of button and then on click call some function which submits form at he end.

    <form id="my_form">
       <span onclick="submit()">submit</span>
    </form>
    
    <script>
       function submit()
       {   
           //do something
           $("#my_form").submit();
       }
    </script>
    
    0 讨论(0)
提交回复
热议问题