Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php dom add class to element

$dom = new DOMDocument;
$dom->loadHTML($html);
$divs = $dom->getElementsByTagName('div');
foreach ($divs as $div) {
        $div->setAttribute('class', $div->getAttribute('class').' myclass');
}
$html = $dom->saveHTML();
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #dom #add #class #element
ADD COMMENT
Topic
Name
5+3 =