我正试图找出如何使用解析器设置不可见的元素。下面是我尝试过的,但不幸的是没有成功:
$button->style = "display:none";
任何想法?由于
使用set setAttribute方法http://php.net/manual/en/domelement.setattribute.php
$button->setAttribute("style", "display:none");
我不知道你在使用哪个解析器,但是如果你想隐藏一些HTML元素,你需要将style
属性设置为display:none
。
那么访问button
的style
属性并设置它/扩展它为display:none
。
根据http://simplehtmldom.sourceforge.net/给出的参考(如果这是您正在使用的组件),应该这样做:
$dom->find("button[id=save]",0)->style = 'display:none';
我的解决方案
$html->find('div[style=display:none]')