开发者

jquery <input type="text" name="quantity[1]" /> get by name

How can I do something like this:

Given:

<input type="text" name="quantity[1]" />

if ($("#开发者_如何学Citem_kit_items").find('input[name=quantity[1]').length ==1)
{
    alert('exists');
}

(The above doesn't work)


You must escape the [] characters. Also, you were missing the closing bracket:

$("#item_kit_items").find('input[name=quantity\\[1\\]]')

Alternatively, you can quote the name:

$("#item_kit_items").find('input[name="quantity[1]"]')


You need to quote it and close the brace.

if ($("#item_kit_items").find("input[name='quantity[1]']").length == 1)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜