Hello,
how can I add <a>
tag as a child of <figcaption>
.
I have tried many solutions, but it didn’t work.
I was able to add e.g. text using createTextNode()
.
const figCaption
is a parent.
Demo:
// WORKING: Added for test, txt will be added as part of figcaption
const txt = document.createTextNode('TEST');
figCaption.appendChild(txt);
// NOT WORKING
const a = figCaption.appendChild(
DOM.create('a', { contentEditable: true }, data.credits)
);
// NOT WORKING
const a = document.createElement('a');
figCaption.appendChild(a);
What’s more if I return the var figCaption
it looks correctly:
JS var:
<figcaption>
<a>Credit text</a>
</figcaption>
but in the DOM <a>
is sibling of <figcaption>
.
DOM:
<figcaption>
</figcaption>
<a>Credit text</a>