Skip to main content

Bug Tracker

Side navigation

#6472 closed bug (fixed)

Opened April 22, 2010 02:33PM UTC

Closed March 30, 2011 08:49PM UTC

Last modified March 13, 2012 08:37PM UTC

$.find with attribute contains selector misses results

Reported by: cmdrkeem Owned by: cmdrkeem
Priority: low Milestone:
Component: selector Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

See the attached html file for an example.

In the case of a table

<table id="table1">


<tr style="display: table-row;"><td>2</td></tr>



I would expect the following 2 alert boxes to contain the same count, 1.

alert($("#table1 tr[style*='table-row']").length); alert($("#table1").find("tr[style*='table-row']").length);

Attachments (2)
  • jquery_error.html (0.6 KB) - added by cmdrkeem April 22, 2010 02:34PM UTC.

    Html file demonstrating the error

  • test.html (0.9 KB) - added by boecko August 03, 2010 09:05PM UTC.

    same issue with empty attributes

Change History (5)

Changed April 22, 2010 11:13PM UTC by dmethvin comment:1

This is because of the attribute-vs-property issue, compounded by an IE bug:

It should be possible to match against the property but I agree it's a problem.

Changed August 03, 2010 09:09PM UTC by boecko comment:2

Here is another test case :

$('#test *[myattr]').length ) == 2 OK

$('#test').find('*[myattr]').length == 1 WRONG

$('#test').find('*[myattr=""]').length == 1 OK

If you add another

<div myattr="">third</div>


$('#test').find('*[myattr=""]').length == 2 STILL OK

Changed October 29, 2010 04:53PM UTC by rwaldron comment:3

owner: → cmdrkeem
priority: → undecided
status: newpending

Please provide a reduced jsFiddle test case, thanks!

Additionally, test against the jQuery 0 GIT version to ensure the issue still exists.

Changed November 22, 2010 01:41AM UTC by jitter comment:4

priority: undecidedlow
status: pendingopen

test case works fine in Opera, Chrome and FF (both alerts say 1). In IE6 (IE7/8 ?) both alerts say 0.

Changed March 30, 2011 08:49PM UTC by danheberden comment:5

resolution: → fixed
status: openclosed

Using style is an awful example, given cross browser support. Here's the selector and .find using a regular attr: