在我的表单中,我以以下方式存储输入:
<input name="tokens[0][A]"> <input name="tokens[1][B]"> <input name="tokens[2][A]">
等。
有没有一种方法可以使用javascript或jquery轻松地获取所有输入,并将[a]作为它们的最终索引?我实际上需要做的就是用一个[A]索引来计算输入的数量。
你可以用 Attribute Ends With
$("input[name$='[A]']")