jQuery event.preventDefault() not working in Firefox (JSFiddle included)

前端 未结 5 543
梦毁少年i
梦毁少年i 2020-12-04 13:17

This is a kind of similar duplicate to some others here, but I think I\'m using event.preventDefault() correctly in this case.

Here\'s a JSFiddle you ca

5条回答
  •  孤城傲影
    2020-12-04 13:37

    I solved it this way, due my code is a little bit different this may be helpful for other people. My initial code looked like this.

    ...

    My js function looked like

    function enrollStudents() {
        // Stop Form.
        event.preventDefault();
        // Other code
    }
    

    I had to pass the parameter event in the function call and receive it in the function.

    ...

    js code:

    function enrollStudents(event) {
        // Stop Form.
        event.preventDefault();
        // Other code
    }
    

    I hope it helps.

提交回复
热议问题