jQuery find parent form

前端 未结 5 1772
名媛妹妹
名媛妹妹 2020-12-07 10:13

i have this html

5条回答
  •  不知归路
    2020-12-07 10:43

    You can use the form reference which exists on all inputs, this is much faster than .closest() (5-10 times faster in Chrome and IE8). Works on IE6 & 7 too.

    var input = $('input[type=submit]');
    var form = input.length > 0 ? $(input[0].form) : $();
    

提交回复
热议问题