I recently discovered PHPDom and found it very useful to manipulate HTML code. Unfortunately the documentation online is limited and there are no comprehensive PHPDom manuals that I am aware of. (There is no PHPdom tag in stockoverflow either!!)
This is the problem I am experiencing.
I would like to change the style an html tag, this is what I am using:
$item = $dom->getElementById($name);
$item->setAttribute('style', 'background-color:#FF0000;');
$item = $dom->getElementById($name.'_error');
$item->setAttribute('style', 'display:true;');
However the result of this code is that the styles defined in $name
and name.'_error'
are overwritten.
To fix the problem, I am looking for a PHPdom method, something like editAttribute, that allows to edit an attribute without overwriting the existing style attributes for that element.
Does anyone know how to fix this problem?