Bug Tracker

Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#6472 closed bug (fixed)

$.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><td>1</td></tr> <tr style="display: table-row;"><td>2</td></tr> <tr><td>3</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 (638 bytes) - added by cmdrkeem 6 years ago.
Html file demonstrating the error
test.html (884 bytes) - added by boecko 5 years ago.
same issue with empty attributes

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by cmdrkeem

Html file demonstrating the error

comment:1 Changed 6 years ago by dmethvin

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


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

Changed 5 years ago by boecko

same issue with empty attributes

comment:2 Changed 5 years ago by boecko

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> then $('#test').find('*[myattr=""]').length == 2 STILL OK

comment:3 Changed 5 years ago by rwaldron

  • Owner set to cmdrkeem
  • Priority set to undecided
  • Status changed from new to pending

Please provide a reduced jsFiddle test case, thanks!

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

comment:4 Changed 5 years ago by jitter

  • Milestone changed from 1.4.3 to 1.5
  • Priority changed from undecided to low
  • Status changed from pending to open
  • Version changed from 1.4.2 to 1.4.4

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

comment:5 Changed 5 years ago by danheberden

  • Resolution set to fixed
  • Status changed from open to closed

Using style is an awful example, given cross browser support. Here's the selector and .find using a regular attr: http://jsfiddle.net/danheberden/E7QH9/1/

Note: See TracTickets for help on using tickets.