#7430 closed bug (invalid)
about parentsUntil()
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | low | Milestone: | 1.5 |
Component: | selector | Version: | 1.4.3 |
Keywords: | parentsUntil | Cc: | |
Blocked by: | Blocking: |
Description
something wrong with this function, e.g. I got a DOM like this <div class=".box">
<div class=".box-inner">
<div>
<p id="text">Hello</p>
</div>
</div>
</div> and $('#text').parentsUntil('.box') got a DOM Element is <div class=".box-inner">...</div> not <div class=".box">...</div>
Change History (2)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → selector |
---|---|
Keywords: | parentsUntil added |
Priority: | undecided → low |
Resolution: | → invalid |
Status: | new → closed |
I believe that Jitter has covered the main issues in this ticket. Namely that parentsUntil doesn't function the way you thought (please see the documentation) and secondly, if you wish to use the code structure we see in your sample, you'll need to escape the periods as mentioned for the code to correctly function.
Note: See
TracTickets for help on using
tickets.
There are some issues with the sample code you gave. But I'll come later to that.
If I understood you correctly you expected
<div class=".box">
to be returned too by$('#text').parentsUntil('.box')
. This isn't how parentsUntil works. The documentation statesSo
parentsUntil
works correctly and returns the parents of#text
up to but not including.box
itself.test case which shows
parentsUntil
works as expected.Issues with your sample code:
The class names in your sample include a period (full stop). Is this intentional or just a typo in the sample code? Because if e.g.
.box
is really the class name you need to escape the period (be it in your jQuery selectors or in your CSS).So
$('#text').parentsUntil('.box')
wouldn't even work because there is no element with classnamebox
(note the missing period). It would need to look like$('#text').parentsUntil('.\\.box')
because you need to escape the period as described in selectors documentation