For example, I have <li>Javascript</li>
and const lenguaje = 'Javascript'
I need to know if what is inside li
bone 'Javascript'
is equal to what is stored in lenguaje
. I tried to do it with this code but it didn't work:
if (document.querySelector('li').innerText === lenguaje) {
document.querySelector('li').remove();
}
You can proceed like this:
querySelectorAll()
to retrieve a list of nodes instead of justquerySelector
which would only return oneul > li
===
to compare strictlyCode
Iterating over all retrieved nodes