开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜