代码之家  ›  专栏  ›  技术社区  ›  Ben G

搜索输入名称

  •  0
  • Ben G  · 技术社区  · 15 年前

    在我的表单中,我以以下方式存储输入:

    <input name="tokens[0][A]">
    <input name="tokens[1][B]">
    <input name="tokens[2][A]">
    

    等。

    有没有一种方法可以使用javascript或jquery轻松地获取所有输入,并将[a]作为它们的最终索引?我实际上需要做的就是用一个[A]索引来计算输入的数量。

    1 回复  |  直到 15 年前
        1
  •  2
  •   Federico klez Culloca    15 年前

    你可以用 Attribute Ends With

    $("input[name$='[A]']")
    
    推荐文章