Side navigation
#9725 closed bug (worksforme)
Opened July 01, 2011 03:58PM UTC
Closed July 02, 2011 03:41AM UTC
Last modified July 02, 2011 07:20PM UTC
Undefined response with multiple find()s on the same object
Reported by: | garytalmes@gmail.com | Owned by: | garytalmes@gmail.com |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | attributes | Version: | 1.6.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I'm using jQuery 1.6.1 (minified) on Firefox 4 (Mac, Snow Leopard).
Say I do this:
$("#mydiv").find("ul.firstlist li a.current").attr("myname");
This yields the expected result.
But now on the next line I do this:
$("#mydiv").find("ul.secondlist li a.current").attr("myname");
This yields "undefined" every time, even though the html is correct and the values are there. It seems that performing a second find() on the same object does not work. And it's not just with attribute calls. I tried applying CSS and that did not work. I also tried to see if I was able to reference $("#mydiv") at all, and I could not.
Workaround: prior to the first find() I make a copy of $("#mydiv") and then perform the second find() on the copy.
Attachments (0)
Change History (3)
Changed July 01, 2011 04:14PM UTC by comment:1
owner: | → garytalmes@gmail.com |
---|---|
status: | new → pending |
Changed July 02, 2011 03:41AM UTC by comment:2
component: | unfiled → attributes |
---|---|
priority: | undecided → low |
resolution: | → worksforme |
status: | pending → closed |
Works fine: http://jsfiddle.net/rwaldron/bwUFD/
Changed July 02, 2011 07:20PM UTC by comment:3
Closer to the description, but yeah it works for me too:
http://jsfiddle.net/dmethvin/bwUFD/1/
garytalmes, this is why a test case is so important. Now two people have taken the time to reproduce the problem and failed.
Thanks for taking the time to contribute to the jQuery project! Please provide a reduced jsFiddle test case 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, we've created this boilerplate: http://jsfiddle.net/rwaldron/da3nM/ Open the link and click to "Fork" in the top menu.