【发布时间】:2011-01-31 21:57:04
【问题描述】:
我目前有以下 JavaScript/jQuery 脚本,它使用 AJAX 获取外部 html 页面并在其所有文本节点上运行一个函数。
$.get('webpage.html', function (html) {
$(html).find('*').each(function () {
$(this).contents().filter(function () { return this.nodeType === 3 }).each(function () {
this.nodeValue = foo(this.nodeValue);
console.log(this.nodeValue);
});
console.log(html);
});
然而,尽管记录的新文本节点值已经改变并且都是正确的,但当我尝试在最后记录 html 时,我只是得到了我开始使用的原始外部网页,其中没有任何修改。
我做错了什么?
DLiKS
【问题讨论】:
标签: javascript ajax jquery