1

我试图弄清楚如何使用解析器设置不可见的元素。这是我尝试过的,但不幸的是:

$button->style = "display:none";

有任何想法吗?谢谢

4

3 回答 3

3

使用 set setAttribute 方法 http://php.net/manual/en/domelement.setattribute.php

$button->setAttribute("style", "display:none");
于 2011-11-19T20:05:30.337 回答
1

我不知道你使用的是哪个解析器,但是如果你想隐藏一些 HTML 元素,你需要将style属性设置为display:none.

所以访问它的style属性button并使用它设置/扩展它display:none

根据http://simplehtmldom.sourceforge.net/提供的参考资料(如果这是您正在使用的组件),应该这样做:

$dom->find("button[id=save]",0)->style = 'display:none';
于 2011-11-19T20:05:12.997 回答
-2

这是我的解决方案

$html->find('div[style=display:none]')
于 2016-05-06T11:09:01.247 回答