Skip to main content

Bug Tracker

Side navigation

#5469 closed bug (worksforme)

Opened November 07, 2009 03:48PM UTC

Closed November 10, 2009 11:52PM UTC

Last modified November 11, 2009 06:28PM UTC

Class selector doesn't work as expected when specifying top

Reported by: fforw Owned by:
Priority: major Milestone: 1.4
Component: core Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description
var $tst =  $("#tst");
$(".foo span", $tst)

does not find the span on this HTML

<div id="tst" class="foo">
	<span>xxx</span>
</div>

I can understand and would expect that code not to regard a ".foo" outside of $tst. But shouldn't it regard the .foo on $tst ?

Attachments (2)
  • select.2.html (0.7 KB) - added by fforw November 09, 2009 10:39AM UTC.

    same test using find, not working either..

  • select.html (0.7 KB) - added by fforw November 07, 2009 03:48PM UTC.

    Test page

Change History (6)

Changed November 08, 2009 03:09AM UTC by dmethvin comment:1

resolution: → worksforme
status: newclosed
$(y,x)
is the same as
$(x).find(y)
, so no. It's best to ask these questions on the forums rather than the bug tracker.

Changed November 09, 2009 10:28AM UTC by fforw comment:2

resolution: worksforme
status: closedreopened

It is *not* working. And it doesn't work with .find() either.

Changed November 09, 2009 10:37AM UTC by fforw comment:3

If you think that is the best and least suprising solution this way and intended behaviour, at least document it as such.

Changed November 10, 2009 11:52PM UTC by dmethvin comment:4

resolution: → worksforme
status: reopenedclosed
It is *not* working. And it doesn't work with .find() either.

That's because you have misunderstood the .find() method, which finds *descendant* elements. Your #tst element is not a descendant of itself.

at least document it as such.

http://docs.jquery.com/Traversing/find#expr

"Searches for descendent elements that match the specified expression."

Changed November 11, 2009 06:26PM UTC by fforw comment:5

The SPAN element I am searching is a descendent.

Changed November 11, 2009 06:28PM UTC by fforw comment:6

I never expected the context itself to be found. I was always searching an descendent. I just expected the context to be regard when looking for the class.