Bug Tracker


Ticket #4618 (closed bug: invalid)

Opened 5 years ago

Last modified 2 years ago

jQuery(html) cannot work well. (bug?)

Reported by: jamesfancy Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:


I am using jQuery 1.3.2, development version. Please check the codes: $(function() {

$.get("t.html", function(data) { $(data).find(":header").each(function() { $("body").append("<div>" + $(this).html() + "</div>"); }); }); $("<h1>1</h1><h2>1.1</h2><h3>1.1.1</h3><div><h1>2</h1><h2>2.1</h2><h3>2.1.1</h3></div>")

.find(":header").each(function() {

$("body").append("<div>" + $(this).html() + "</div>");



Below things are shown in IE: 2 2.1 2.1.1

Expect ouput: 1 1.1 1.1.1 2 2.1 2.1.1

The headers out of "<div></div>" cannot be found by ":header" selector.


test.html Download (655 bytes) - added by jamesfancy 5 years ago.
The sample file. jquery.js should be put into the same directory.

Change History

Changed 5 years ago by jamesfancy

The sample file. jquery.js should be put into the same directory.

comment:1 Changed 5 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

The .find() method finds elements *below* the elements you provide in the DOM tree. That's why the ones in a <div> are found but the ones immediately in the jQuery object are not. For more help, compare the documentation of .find() to .filter() and please ask for help on the forums before filing bugs to make sure they're bugs.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Add a comment

Modify Ticket

as closed

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.