パーサーを使用して要素を非表示に設定する方法を見つけようとしています。これが私が試したもので、残念ながらうまくいきませんでした:
$button->style = "display:none";
何か案は?ありがとう
setAttribute メソッドを使用 http://php.net/manual/en/domelement.setattribute.php
$button->setAttribute("style", "display:none");
どのパーサーを使用しているかわかりませんが、一部の HTML 要素を非表示にする場合は、style
属性をに設定する必要がありますdisplay:none
。
style
そのため、その属性にアクセスしbutton
て設定/拡張しdisplay:none
ます。
http://simplehtmldom.sourceforge.net/で与えられた参照によると(それがあなたが使用しているコンポーネントである場合)、これはそれを行うはずです:
$dom->find("button[id=save]",0)->style = 'display:none';
ここに私の解決策
$html->find('div[style=display:none]')