I have the form below; I changed the submit button to just type “Button” so that I can run some JavaScript before submitting the form:
Here is my form:
<form action="/Cart" method="post"> <input type="hidden" name="name" value="12" /> <input type="button" class="addToCartButton" value="Add to Cart" /> </form>
Here is my initial event handler:
$(document).ready(function () { $('.addToCartButton').click(function () {
I have several of these forms on one page, so I need to relatively refer to the form and some other inputs inside this form. What is the best way to do this? I thought about putting some kind of prefix that would be unique for each form, and then use this in a selector, but that seems very hacked ...
leora source share