Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

309
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda