0
I am trying to add a variable that contains an html element in my html file, I am trying to use innerHTML += mykey, the problem is, I have two elements to add, an iframe and a paragraph, when add iframe goes well, but the paragraph does not add.
function inserir() {
let nomeVideo = document.querySelector('#nome-video').value;
let linkVideo = document.querySelector('#link-video').value;
let itemVideo = `<div class="items-video">
<iframe src="${linkVideo}" frameborder="0" allowfullscreen>
<p>${nomeVideo}</p>
</div>`;
document.querySelector('#conteudo-videos').innerHTML += itemVideo;
}
<!--html-->
<div class="container-items" id="conteudo-videos">
</div>
What could I be doing wrong ?? remembering that I’m starting right now in javascript, so forgive the noobise.
I forgot to close the iframe
– Gabriel Chelles