Multiple Forms on a Single Page - JQuery
I have multiple forms on a single page with the same named variables within each form.
I need to be able to changed the specific values for one form but not the others.
Ie.
I want to be able to set the value of Var2 for form2, but not the values of Var2 for form1.
Any ideas?
开发者_开发百科Thanks
Ideally, give the forms their own IDs and use the Descendant Selector:
$("#form1 input[name=foo]").val("something");
or select it by the order in which it appears in the DOM using eq
(as Alxandr points out):
$("form:eq(0) input[name=foo]").val("something"); // select the first form
精彩评论