I\'m trying to submit a form from a link that is located in my nav bar.
I\'m new to javascript.jQuery and unsure why this won\'t execute.
I have a feeling there
Link:
Save
jQuery:
$(document).ready(function() {
$('#add-product-save-link').click(function() {
$('#add-product-form').submit();
});
});
You don't need the e.preventDefault(), because your anchor tag isn't going anywhere (the href is #
).
Because your tag's action attribute is blank, that means that the form will submit itself to this same document. If that is what you want to do, then you can put the logic for that at the top of your document:
Finally, because this answer uses jQuery, ensure that you reference the jQuery library somewhere, such as in the tags: