【发布时间】:2017-02-28 03:51:11
【问题描述】:
$iframes = $doc->getElementsByTagName('iframe');
foreach ($iframes as $iframeViejo) {
$iframeMainn = $doc->createElement('iframe');
$iframeNuevo->setAttribute('src', $iframeViejo->getAttribute('src'));
$iframeNuevo->setAttribute('width','560');
$iframeNuevo->setAttribute('height','615');
$figureNuevo = $doc->createElement('figure');
$figureNuevo->setAttribute('class','op-interactive');
$figureNuevo->appendChild($iframeNuevo);
$iframeViejo->parentNode->replaceChild($figureNuevo, $iframeViejo);
}
但我想添加另一个 iframe 标记,因为我想要这个输出:
<figure class="class"><iframe><iframe src="src" width="xxx" height="xxx"></iframe><iframe></figure>
你能帮帮我吗
【问题讨论】:
-
通过 for 循环添加 iframe,然后单独添加?这是你要求的吗?
-
是的,我需要添加另一个 iframe
-
$iframeNuevo 是什么对象