SyntaxFix
Write A Post
Hire A Developer
Questions
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.
.closest()
var input = $('input[type=submit]'); var form = input.length > 0 ? $(input[0].form) : $();