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

221
Views
Uncaught TypeError: Cannot read properties of undefined (reading 'remove')

What's the problem in my code?

Uncaught TypeError: Cannot read properties of undefined (reading 'remove')

and

Uncaught TypeError: Cannot read properties of undefined (reading 'add')

document.querySelector("#elastic").oninput = function () {
    let val = this.value.trim();
    let elasticItem = Array.from(document.querySelectorAll(".elastic li"));
    if (val != "") {
        elasticItem.forEach(function (elem) {
            if (elem.innerText.search(val) === -1) {
                elem.classlist.add("hide");
            } else {
                elem.classlist.remove("hide");
            }
        });
    }
};
.hide {
  display: none;
}
<div>
    <input type="text" id="elastic" placeholder="Search" />
</div>

<div>
    <ul class="elastic">
        <li>ht</li>
        <li>sdf</li>
        <li>qwe</li>
        <li>cxv</li>
        <li>sad</li>
        <li>sdf</li>
        <li>dfg</li>
    </ul>
</div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

JavaScript is case-sensitive

Change
classlist to classList (l → L)

elem.classList.add('hide');
elem.classList.remove('hide');
about 4 years ago · Juan Pablo Isaza Report
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!