document.querySelector('#movies').innerHTML = `
<div class="row">
<div class="alert alert-primary w-50 mb-2" role="alert">
New genre added.
</div>
</div>
<div class="row">
<div class="card mb-2 w-50">
<div class="card-body">
<h5 class="card-title">${name}</h5>
</div>
</div>
</div>
`;
From the code snippets, I am trying to select those elements with .card-title
class
const cardsList = document.querySelectorAll('.card-title');
console.log(cardsList);
but it keeps on returning an empty NodeList
.
Is it really not possible to target those elements added using innerHTML
property after the DOM has been created and the page already loaded?