Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
Searches through the whole div

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.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!