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

301
Views
Cannot read properties of undefined (reading 'className')

Here is the js function that includes the className property:

function filterSelection(f){
var c, i;
c = document.getElementsByClassName("filterDiv");
if(f=="all") f="";
for(i = 0; i<c.length ;i++){
    classRemove(c[i], "show");
    if(c[i].className.indexOf(f) > -1) classAdd(c[i],"show");
}

}

I copied it straight from w3schools, with a few changes to variable names but that's it. Does the placement of my script tag have anything to do with this?

Here's the HTML code it applies to:

<div id = "btnContainer">
    <button class = "btn active" onclick = "filterSelection('all')"> All classes</button>
    <button class = "btn" onclick ="filterSelection('myclasses')"> My classes</button>
</div>
<div class = "container">
    <div class = "filterDiv <?php echo $bookmark1;?>">
    Test Class 1
    <button id = "addBtn-1" onclick = "noneAdd();add()">Add to My Classes</button>
    <button id = "removeBtn-1" class = "none" onclick = "noneRemove();remove()">Remove from My Classes</button>
    </div>
</div>

Ignore all the other elements, they most likely don't work but I'm confused as to why I'm getting this error specifically since it was a copy of w3schools' code.

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!