Submit an HTML form without having a submit button?

前端 未结 11 1368
攒了一身酷
攒了一身酷 2021-01-01 18:57

Can I submit a html

with
instead of ?

Like this:

         


        
11条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 19:43

    For better semantics and graceful degradation, I suggest you do this:

    $(document).ready(function(){
        $('form input[type="submit"]').replaceWith('
    Submit the form by clicking this
    '); // replace submit button with div $('.submit').live('click', function() { $(this).closest('form').submit(); }); });

    This way, your form remains usable for clients without JS.

    That being said: Just style your input to look the way you want it to with CSS ;)

提交回复
热议问题