As a result, I’ve missed out on a lot of js goodies. And, with it entering a renaissance of sorts, it’s high time I learn some.
One of the things I’ve had to work around are these hoity-toity designers who don’t like to use typical “submit” buttons for form submissions when they’re designing forms. They like to use anchor tags, presumably because they’re more easily styleable. So, how does one submit a form without a submit button?
Here’s one way I’ve learned:
// Other arbitrary code here
<a href="#" onclick="$(this).parents('form').submit();">Your text</a>
// More arbitrary code here
“this” presumably refers to the a href tag. You then call submit() on its parent form. Pretty cool.