【问题标题】:PhpQuery and replaceWith, How to?PhpQuery 和 replaceWith,如何?
【发布时间】:2011-06-28 07:31:49
【问题描述】:

我正在使用 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>

但是什么也没发生。谁能给我一些线索?

最好的问候

【问题讨论】:

  • 您是否尝试使用pq() 选择器而不是find

标签: php phpquery replacewith


【解决方案1】:

尝试使用 iframe 元素的 id:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多