I try to append a button on a div element, that isn't defined in the html page.
This is my Function to create the Button:
const img2dView = function (name) {
return `<button class="gridButton">
<img alt = ${name} src="$...images/${name}.png" style="width: 100%;">
</button>`;
};
if i append this on an already defined div it works:
$someDiv.append(img2dView(SomeName));
but if i try this on a new created div, the button is just a string:
let helpDiv = document.createElement('div');
helpDiv.class = 'square';
helpDiv.append(img2dView(SomeNames[i]));
Output:
<div>
"<button class="gridButton">
<img alt = blocked src="assets/.....png" style="width: 100%;">
</button>;"
</div>
I think i need .appendChild. But then I get a error Message, that "img2dView(SomeNames[i])" isn't a node