且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

一个形成两个动作

更新时间:2022-12-11 07:57:28

HTML5有 formaction 属性

<form action="/url" id="myForm">
     <input type="submit" value="save1" formAction="/url1" />
     <input type="submit" value="save2" formAction="/url2" />
</form>

如果需要,这里是备用。

Here is a fallback if you need it.

if (!('formAction' in document.createElement('input'))){
 $('form').on('click', 'input[type=submit]', function (e) {
    var attr = this.getAttribute('formAction');

    if (attr) {
        this.action = attr; //Set the form's action to formAction
    }
  });
}