#7581 closed bug (invalid)
.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: |
Description
Hey,
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: http://lab.codecookie.net/jquery_array_selector/
greets
Change History (6)
comment:1 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 follow-up: 3 Changed 12 years ago by
yeah but if you had looked at my example you would have seen that I escaped it! $("input[name=names
[
]]").size()
greets
comment:3 Changed 12 years ago by
ok here it looks not the right way.
I put two backslashes before each [ and ]
greets
comment:4 Changed 12 years ago by
Cc: | anonymous added |
---|
If you would like us to re-open this ticket, please re-recreate your test case on jsFiddle.net 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.
comment:5 Changed 12 years ago by
comment:6 Changed 12 years ago by
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.
This is not a bug, just an improperly escaped selector.
If you have a look at http://api.jquery.com/category/selectors/, 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.
Cheers.