Using jQuery to submit form from link outside of form

后端 未结 4 1695
攒了一身酷
攒了一身酷 2021-02-10 10:38

I\'m trying to submit a form from a link that is located in my nav bar.

I\'m new to javascript.jQuery and unsure why this won\'t execute.

I have a feeling there

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-10 11:04

    You are clicking in the "A", not in the Italic (With ID). Supposing you will not change the HTML to that work out you should use this:

    $(document).ready(function() {  
        $('#add-product-save-link').parent().click(function(e) {
            $('#add-product-form').submit();
            return false;
        });
    });
    

提交回复
热议问题