$.ajax({
url: "getHTML.php",
data: {url: "http://www.google.com"},
success: function(e){
var html = e;
$('img', html).each(function(){
$(this).attr("src", "http://google.com/logo.jpg");
});
$('a', html).each(function(){
$(this).attr("href", "http://google.com/");
});
$('body').html(html);
}
});
Run Code Online (Sandbox Code Playgroud)
但基本上,没有设置变化.
$(this).attr("src", "http://google.com/logo.jpg");
Run Code Online (Sandbox Code Playgroud)
返回带有google徽标的片段作为源属性,但是
$(this).replaceWith($(this).attr("src", "http://google.com/logo.jpg"));
Run Code Online (Sandbox Code Playgroud)
不行.