.find()gets only descendants, not from the current level, you need .filter()to get elements from the current set (which is the root of what you returned), for example:
function ajaxReturn(data) {
alert($(data).filter('.event-detail').length);
alert($(data).find('.copy').length);
}
If you want to .find()work in both cases, add content to the parent container, for example:
function ajaxReturn(data) {
var parent = $("<div />").append(data);
alert(parent.filter('.event-detail').length);
alert(parent.find('.copy').length);
}
source
share