【发布时间】:2017-05-22 03:29:42
【问题描述】:
我想从外部站点上的特定 div 中提取一些数据,将 URL 预先附加到 img src 链接,这些链接是相对的,以使其成为绝对值,然后将该 html 放入 div 中。忽略跨站问题...
jQuery(document).ready(function() {
var $thePage = jQuery('<div>');
jQuery($thePage).load("https://example.com div.myitem");
jQuery($thePage).find('img').attr('src', function (i, src) {
var newsrc = "https://example.com" + src;
return newsrc;
});
jQuery("#testdiv").html($thePage);
});
html 显示在 div 中,但 img 链接没有更新。任何想法将不胜感激!
【问题讨论】:
-
目前的结果和预期的结果是什么?
标签: javascript jquery html