※ 引述《averywu (看文不要只會用橫的看)》之銘言:
: 請問要怎麼使用Jquery 選取不特定長度陣列元素呢?
: <input type="text"id="goods[1]">
: <input type="text"id="goods[2]">
: <input type="text"id="goods[3]">
: 其中,goods[X]的X不是固定的,數量也不會固定。
: 我試過 $('#goods[*]').size();
: 是沒用的。有什麼比較直接的方法呢?
你的 id 在 html5 是沒問題的,但在 html4 是不合規定的:
http://www.w3.org/TR/html401/struct/global.html
id = name [CS]
This attribute assigns a name to an element. This name must be unique in
a document.
http://www.w3.org/TR/html401/types.html#type-name
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by
any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
colons (":"), and periods (".").
如果你能動到 template,修改完 id 後用 class 補上會比較好。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.242.135.97