DiDOM
DiDOM copied to clipboard
Strange behavior by dublicating elements
Hi!
I have the following HTML code:
<div id="hero_techSpec">
<br/>
<br/>
<strong>Technische Daten:</strong><br/>
<br/>
<div class="hero_techSpecItem">
<strong><span class="techSpec_liSign">»</span> <span class="hero_techSpecItemName"></span>:</strong> <span class="hero_techSpecItemValue"></span><br/>
</div>
</div>
The element with class "hero_techSpecItem" I have to dublicate.
I tried the following:
$techSpec = $document->first("#hero_techSpec");
$techSpecItemTemplate = $techSpec->first(".hero_techSpecItem");
$techSpecItemNew = clone $techSpecItemTemplate;
/** @var Element $techSpecItemName */
$techSpecItemName = $techSpecItemNew->first(".hero_techSpecItemName");
echo $techSpecItemName->html();
$techSpecItemName->setInnerHtml($value->getSpecification()->getName());
echo $techSpecItemName->html();
/** @var Element $techSpecItemValue */
$techSpecItemValue = $techSpecItemNew->first(".hero_techSpecItemValue");
$techSpecItemValue->setInnerHtml($value->getValue());
echo $techSpecItemNew->html(); die;
$techSpec->appendChild($techSpecItemNew);
Very interesting is "echo" number 2 and 3. Number 2: Everything is inserted fine. However, in the third "echo", there is the old state again.
Do you have any ideas, why this happens as it happens?
Thank you!
Tobias