Reputation: 94309
Assume that in
$.ajax({
url: 'page1.html',
data: {},
success: function (data) {
$(data) //return an array of nodes
},
dataType: 'html'
});
$(data)
returns an array of nodes:
[<div id="a">,
<div id="b">, //3 elements
<div id="c">]
and I want to get the HTML of the div that has an id
of "b"
. I tried
$(data).find("#b");
but it returns a blank array. ([]
) So how can I select it? Please help.
Upvotes: 0
Views: 46
Reputation: 186562
$(data).filter('#b')
you should use filter instead of find, since there's no parent element for all of those elements so no higher level context to find from.
Upvotes: 1
Reputation:
Upvotes: 2