I have this script:
function search_animal() {
let input = document.getElementById('searchbar').value
input = input.toLowerCase();
let x = document.getElementsByClassName('separateline');
for (i = 0; i < x.length; i++) {
if (!x[i].innerHTML.toLowerCase().includes(input)) {
x[i].style.display = "none";
}
else {
x[i].style.display = "";
}
}
}
Then I have this multiple divs with this class
<div class="separateline">
<a class="tabcontentlink" href="shablon.html">Dog</a>
<p class="line"></p>
</div>
However when I use a search bar it searches through the whole div, when I need it to search only through the visible text "Dog". For example if I enter "tabcontentlink" in the search bar it will find all the divs, because all of them are named like this and the biggest problem is if I enter parts of the word "tabcontentlink" it will still find it.