event.preventDefault() working in Chrome, not Firefox for a submit button

后端 未结 5 1021
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-18 06:11

I have the following submit button:

 

When I use the follo

5条回答
  •  盖世英雄少女心
    2021-01-18 06:23

    You did not add the event to the function parameters.
    fixed version:

    $(document).ready(function(){
            $("#submit").submit(function(event){
                    event.preventDefault();
                    console.log('test');
            }
    });
    

提交回复
热议问题