Opened 12 years ago
Closed 12 years ago
#7077 closed bug (invalid)
.find not working with first element
Reported by: | ScaredyCat | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.3 |
Component: | core | Version: | 1.4.2 |
Keywords: | find ajax | Cc: | |
Blocked by: | Blocking: |
Description
.find doesn't appear to work if the searched for element is the first element it encounters.
Assume I have a page with a table on it that has an id of 'cheese', I want to make an ajax call to replace the table.
If I return:
<table id='cheese'><tr><td>Something</td></tr></table>
from an ajax call
$.ajax({
type: 'GET, url: 'something.php', dataType: "html", success: function(data) {
var $response=$(data); var ourdata = $response.find('#cheese');
$('#cheese').replaceWith(ourdata);
});
jQuery doesn't find the table. If I wrap the table in, for example
<div id='fake'> <table id='cheese'><tr><td>Something</td></tr></table> </div>
jQuery will find it.
You want
.filter
, not.find
. In the future, please use the jQuery Forum for support requests.