How to reference input elements within a specific scope when there are multiple input elements of same kind?
- by Will Merydith
How do I select data for input elements within a specific scope? I have the same form multiple times (class "foo-form), and want to ensure I get the values for the hidden inputs within the scope of the form being submitted. Is the scope "this" implied? If not, what is the syntax for selecting input class "foo-text" within the scope of this? Feel free to point me to examples in the jquery docs - I could not find what I was looking for.
$('.foo-form').submit(function() {
// Store a reference to this form
var $thisForm = $(this);
});
<form class="foo-form">
<input type="hidden" class="foo-text"/>
<input type="submit" class="button" />
</form>
<form class="foo-form">
<input type="hidden" class="foo-text"/>
<input type="submit" class="button" />
</form>
<form class="foo-form">
<input type="hidden" class="foo-text"/>
<input type="submit" class="button" /> // user clicks this submit button
</form>