Is there a better jQuery solution to this.form.submit();? Is there a better jQuery solution to this.form.submit();? jquery jquery

Is there a better jQuery solution to this.form.submit();?


I think what you are looking for is something like this:

$(field).closest("form").submit();

For example, to handle the onchange event, you would have this:

$(select your fields here).change(function() {    $(this).closest("form").submit();});

If, for some reason you aren't using jQuery 1.3 or above, you can call parents instead of closest.


this.form.submit();

This is probably your best bet. Especially if you are not already using jQuery in your project, there is no need to add it (or any other JS library) just for this purpose.


I have found that using jQuery the best solution is

$(this.form).submit()

Using this statement jquery plugins (e.g. jquery form plugin) works correctly and jquery DOM traversing overhead is minimized.