Answers for "php dom add class to element"

PHP
1

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();
Posted by: Guest on April-07-2021

Code answers related to "php dom add class to element"

Browse Popular Code Answers by Language