#4428 closed bug (invalid)
SELECTOR doesn't work
Reported by: | simonxy | Owned by: | john |
---|---|---|---|
Priority: | critical | Milestone: | 1.4 |
Component: | selector | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
If I use the following selector:
$('~ span:first', this) doesn't work - it won't found any element. (this is input element, but it doesn't matter)
If I remove :first, than it works. $('~ span', this) - THIS WORKS.
In old library 1.2.1.js the first example works: $('~ span:first', this) - THIS WORKS IN PREVIOUS LIBRARY.
Attachments (2)
Change History (4)
Changed 14 years ago by
Attachment: | bamboo.zip added |
---|
Changed 13 years ago by
Attachment: | testcase.html added |
---|
here is a simplified test case that shows the seelctor problem.
comment:1 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Your test case is using invalid HTML (for this particular problem) which is why your code is likely failing. If you wish to find a child element belong to a particular parent, you need to have that child actually be a child *of that parent* rather than outside of it. Not doing so would render your test case to not function correctly which is what is happening here.
comment:2 Changed 12 years ago by
Why would his HTML be invalid? He doesn't want to find a child, he wants to find a sibling. ~
is the Next Siblings Selector.
In this case he wants to find all/first span sibling of every div.
I made a test case. If you switch between the various jQuery version you will notice that
jQuery 1.2.6 returned 1
for all tests
jQuery 1.3.2 returns 0 for Test 2 and Test 4
jQuery 1.4.3 fails to return 1 for all tests but Test 5.
This is a serious regression getting worse since jQuery 1.2.6
example of this selector