jQuery doesn't submit a form

前端 未结 4 1734
借酒劲吻你
借酒劲吻你 2020-12-06 01:02

I have the following HTML code:





        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-06 01:49

    I think you fire the submit event before the DOM is actually loaded, because if I try it, this code works:

    $(document).ready(function(){
    
        // Submit handler, to prove everything works fine
        $('#umfrageForm').submit(function(){
            alert('hi');
            return false;
        });
    
        // Fire the submit event
        $('#umfrageForm').submit(); // alerts 'hi'
    });
    

    See: jsFiddle

提交回复
热议问题