Javascript select onchange='this.form.submit()'

前端 未结 6 1117
忘了有多久
忘了有多久 2020-12-01 05:42

I have a form with a select and a few text inputs. I\'d like the form to be submitted when the select is changed. This works fine using the following:

onchan         


        
6条回答
  •  难免孤独
    2020-12-01 05:46

    You should be able to use something similar to:

    $('#selectElementId').change(
        function(){
             $(this).closest('form').trigger('submit');
             /* or:
             $('#formElementId').trigger('submit');
                or:
             $('#formElementId').submit();
             */
        });
    

提交回复
热议问题