Submitting a form by pressing enter without a submit button

前端 未结 20 1852
你的背包
你的背包 2020-11-22 06:46

Well I am trying to submit a form by pressing enter but not displaying a submit button. I don\'t want to get into JavaScript if possible since I want everything to work on a

20条回答
  •  Happy的楠姐
    2020-11-22 07:02

    I added it to a function on document ready. If there is no submit button on the form (all of my Jquery Dialog Forms don't have submit buttons), append it.

    $(document).ready(function (){
        addHiddenSubmitButtonsSoICanHitEnter();
    });
    function addHiddenSubmitButtonsSoICanHitEnter(){
        var hiddenSubmit = "";
        $("form").each(function(i,el){
            if($(this).find(":submit").length==0)
                $(this).append(hiddenSubmit);
        });
    }
    

提交回复
热议问题