繁体   English   中英

PhpQuery和replaceWith,如何?

[英]PhpQuery and replaceWith, How to?

我使用的是PhpQuery,需要为另一个代码替换“ iframe”

html文件具有Iframe

<div id="content">
    <div class="pad3"></div>
        <iframe src="http://www.yahoo.com" id="iFrame"></iframe>
    <div class="pad2"></div>
</div>

惠特这块

$doc = phpQuery::newDocumentFileHTML('file.htm');
$doc->find('iframe')->replaceWith('<p>test</p>');

我期望这样:

<div id="content">
    <div class="pad3"></div>
        <p>test</p>
    <div class="pad2"></div>
</div>

但是什么也没发生。 有人可以给我一些线索吗?

最好的祝福

尝试使用iframe元素的ID:

$doc->find('#iFrame')->replaceWith('<p>test</p>');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM