jQuery 和表单对象数组 [英] jQuery and Form Object Array

查看:55
本文介绍了jQuery 和表单对象数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是关于具有相同名称和未知数量的克隆/重复项的表单输入对象,例如:

This is about form input objects with same names and unknown number of clones/duplicates such as this one:

<input name="field[]" id="field[]" value="">

使用 jQuery,我动态添加对象的副本,理论上使其看起来像这样:

using jQuery, I dynamically add copies of the object which theoretically makes it look like this:

<input name="field[]" id="field[]" value="">
<input name="field[]" id="field[]" value="">
<input name="field[]" id="field[]" value="">
<input name="field[]" id="field[]" value="">

...等等等等.

问题:你能告诉我我们是否引用了这样的对象,例如,使用一个 on-change 过程.

Question: Could you show me do we reference such objects, say for example, with a on-change procedure.

提前致谢.

推荐答案

多个元素具有相同的 ID 是无效的.

It is not valid to have multiple elements with the same ID.

您可以使用以下方法获取第 n 个输入:

You can get the n-th input using:

$('input').eq(n)

这篇关于jQuery 和表单对象数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆