Reputation: 13213
How do you find out if the data retreived from a .get()
request contains html with a certain selector?
$.get(url,function(data){ alert( data.find("#myid").length ) });
Doesn't seem to work.
Upvotes: 0
Views: 68
Reputation: 382112
Supposing data is some HTML, use
$(data).find("#myid").length
or this more reliable solution if your document isn't well formed :
$("<div>").html(data).find("#myid")
Upvotes: 4