How to make a submit out of a <a href...>...</a> link?

fmsf picture fmsf · Nov 8, 2008 · Viewed 266.2k times · Source

I got an image with which links to another page using <a href="..."> <img ...> </a>.

How can I make it make a post like if it was a button <input type="submit"...>?

Answer

Paulius Zaliaduonis picture Paulius Zaliaduonis · Nov 3, 2011

More generic approatch using JQuery library closest() and submit() buttons. Here you do not have to specify whitch form you want to submit, submits the form it is in.

<a href="#" onclick="$(this).closest('form').submit()">Submit Link</a>