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)
精彩评论