Skip to main content

Bug Tracker

Side navigation

#7581 closed bug (invalid)

Opened November 20, 2010 09:28AM UTC

Closed November 20, 2010 05:08PM UTC

Last modified November 20, 2010 07:06PM UTC

.size() returns 1 on multiple objects

Reported by: Owned by:
Priority: undecided Milestone: 1.5
Component: unfiled Version: 1.4.4
Keywords: Cc: anonymous
Blocked by: Blocking:


I don't know if this is a bug but I think so.

I tried to select <input name="names[]"/> with $('input[name=names\\\\[\\\\]').size() and it returns zero!

The same with an ID But then it returns 1. <input id="names"/> with $('#names').size()

It works if I do it with a class (.names)

Here is a demo:


Attachments (0)
Change History (6)

Changed November 20, 2010 05:08PM UTC by miketaylr comment:1

resolution: → invalid
status: newclosed

This is not a bug, just an improperly escaped selector.

If you have a look at, you can see your exact example is covered:

"If you wish to use any of the meta-characters (#;&,.+*~':"!^$[]()=>|/@ ) as a literal part of a name, you must escape the character with two backslashes. For example, if you have an an input with name="names[]"...", etc.

The #jquery IRC channel on Freenode or the support forums are also a great way to ask these types of questions.


Changed November 20, 2010 05:11PM UTC by anonymous comment:2

yeah but if you had looked at my example you would have seen that I escaped it! $("input[name=names\\\\[\\\\]]").size()


Changed November 20, 2010 05:13PM UTC by anonymous comment:3

ok here it looks not the right way.

I put two backslashes before each [ and ]


Changed November 20, 2010 05:40PM UTC by addyosmani comment:4

cc: → anonymous

If you would like us to re-open this ticket, please re-recreate your test case on so that we can evaluate it correctly. Note: the bug tracker is known to remove/interpret certain characters differently so characters you may have used in your original submission may not have been visible to us.

Changed November 20, 2010 05:46PM UTC by comment:5


here is the test case on



Changed November 20, 2010 07:06PM UTC by jitter comment:6

Thanks providing the test case! jQuery requires the uses of quotes when using attribute selectors not matter if you escape or not the meta characters.

test case