Ajax/JQuery 多个 .load() 请求不包括 .wrap() 内容?

Ajax/JQuery Multiple .load() Requests Not Including .wrap() Content?

我不确定这的衍生原因是什么,但我正在寻找 call/.load() 从一页到另一页的特定内容部分,虽然我一直能够检索一些目标内容,该函数似乎没有在调用中添加任何 .wrap() 选择器,我已将其实现为单独的脚本(如下所示)。

例如,这里是 .wrap() 函数(检索 .load() 时未遵守):

$("iframe.selectediframe").wrap("<div class='wraptoiframe'></div>");

.load() 函数,它检索请求的 iframe 内容,但不在 ids 中应用任何指定的 .wrap() 选择器(例如:.wraptoiframe):#section(x) 目标:

$('#embed-content1').load('https://URL1.com/ #section1');
$('#embed-content2').load('https://URL2.com/ #section2');

然后我就这样实现了 HTML:

<div id="embed-content"></div>

如何强制多个 .load() 在其执行中包括所有已选择到 .wrap(),但只调用包装函数一次?

使用完整的回调并在每个容器中查看要包装的元素

function wrapIframe(){
   // "this" is the embed-content container that is being populated
   $(this).find("iframe.selectediframe").wrap("<div class='wraptoiframe'></div>");
}
// pass wrapIframe as reference for complete callback of load
$('#embed-content1').load('https://URL1.com/ #section1',wrapIframe);
$('#embed-content2').load('https://URL2.com/ #section2', wrapIframe);