Long time lurker, first time poster. I've searched a bit, and haven't
found exactly what I need. I was wondering if someone here could help.
I want to make an unobtrusive bit of Javascript that will replace all
submit buttons with a text link (that I can style) that will submit
the form.
I want to make this as generic as possible, so I don't want to attach
an ID to the form to submit. It should just submit the parent form.
This is the code that I came up with that doesn't work:
$(document).ready(function(){
$('[EMAIL PROTECTED]').after("<a href='#' class='button'>Button
Text</a>").hide();
$('[EMAIL PROTECTED]').next().bind( "click", function() {
$(this).prev().submit();
});
});
1) The first line creates a the link after any submit buttons, then
hides the submit button.
2) The second line (theoretically, at least) binds a click event to
the newly created link. A click on the link should fire the submit
trigger on the previous item, which is the original submit button.
Line #2 doesn't work. I can bind events to the link, but it will not
submit the form. I've searched around quite a bit, but haven't found
exactly how to submit the form. Again, I want to make this as generic
as possible, so I don't want to attach a hard coded ID of the form to
submit. It should just submit the parent form.
Can you give me a pointer to fix this?
Bonus points, if you want to extend it to all buttons. :-)
Cheers and thanks in advance,
p.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/