This selector doc.getElementsByClassName('value') needs to target the td element which is the next sibling of another td which has the text "sign here" so that the image appended after the "abc:".
How can it be done? Thanks
let w = window.open();
let doc = w.document;
doc.write(raw_html);
doc.close();
let sigImg = new Image();
sigImg.src = signature;
doc.getElementsByClassName('value').appendChild(sigImg); //wrong selector
There are many of td and tr element with different class and values.
<tr>
<td class="label">sign here</td>
<td class="value">abc:</td>
</tr>
edit
The element index is not known in advance. only that it is after another td element which has its text equal to "sign here"
signature?getElementsByClassNamereturns an array-like nodelist. Just access whichever element thru subscriptgetElementsByClassNamereturns aNodeList. TryquerySelectorwhich takes a CSS selector and returns the first element that matches.querySelectorfilter out the results by the text inside the td being "sign here"? and if so, how? can you show in an answer? thxidon the element you need and be done with it.