Ticket #11740 (closed bug: worksforme)
.not() method
| Reported by: | leonardo@… | Owned by: | leonardo@… |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I have this html structure. <div class="collapsible">
<div class="collapsor">click me</div> <div class="collapsing">I'm hidden</div>
<div> <div class="collapsible">
<div class="collapsor">click me 2</div> <div class="collapsing">I'm hidden 2</div>
<div>
It's a basic accordion, so on initialization I want to collapse all the ".collapsing", except for the first one. I thought to do: $(".collapsing").not('.collapsible:first>.collapsing').hide(); but this doesn't work! infact the selection and the subsequent .not() result in an empty array. I realized this must be a bug because if I call: $(".collapsing",context).not($('.collapsible:first>.collapsing')).hide(); it works. (notice the call to $() inside the .not())
Change History
comment:1 Changed 13 months ago by rwaldron
- Owner set to leonardo@…
- Status changed from new to pending
comment:2 Changed 13 months ago by leonardo@…
- Status changed from pending to new
I should really learn to read the guidelines *before* posting. But unfortunately I don't seem to be able to reproduce the effect on jsFiddle. It works as expected there, there is no difference between the two examples I made above. This isn't true for my webpages though. I'm using jQuery 1.7.2. :/
comment:3 Changed 13 months ago by rwaldron
Are you using TinyMCE? If so, you may want to upgrade to the latest version - this sounds like a report we previously received that turned out to be caused by TinyMCE
comment:4 Changed 13 months ago by leonardo@…
No I'm not using TinyMCE. I have made a static snapshot of my page. You can visit it here: http://bss.rel.to/test_collapse.html The code is in the ./js/collapse.js file As you can easily test with a JS console, the set returned by
$(".collapsing",context).not($('.collapsible:first>.collapsing'))
is not the same of
$(".collapsing",context).not('.collapsible:first>.collapsing')
but, unless I'm interpreting wrong the .not() documentation, they should be equivalent.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!
Additionally, be sure to test against the "jQuery (edge)" version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to begin.