在$ .AJAX加载的HTML上使用Jquery选择器? [英] Use Jquery Selectors on $.AJAX loaded HTML?

查看:88
本文介绍了在$ .AJAX加载的HTML上使用Jquery选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有

$.ajax({
  url: identity,
  success: function(data) { ProcessIdentityServer(data) }
});

返回数据"时,有一种方法可以针对选择器运行选择器,而无需将其添加到DOM中.因此,例如,如何获取包含在数据"中的HTML中包含的任何LINK标记的所有href值,而无需先将其添加到DOM中?如果我只想将某些内容提取到数组中,似乎不得不将其添加到DOM中似乎很可惜.任何人有任何想法吗?

When 'data' is returned, is there a way to run selectors against it without adding it into the DOM. So for example, how can I get all the href values of any LINK tags contained in the HTML held in 'data' without adding it to the DOM first? Seems a shame to have to add it into the DOM if all I want to do is extract some stuff into an array. Anyone got any ideas?

推荐答案

// Finds all div elements within an XML document from an AJAX response.
$("div", xml.responseXML);

这篇关于在$ .AJAX加载的HTML上使用Jquery选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆