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

367
Vistas
Why my html(Javascript) code doesn't work in vsCode?

this is a simple code that helps HTML to execute a code that will open a box-modal. But for whatever reason, it doesn't seem to do anything while I write it in Vscode but it works perfectly fine while I write it in 'code-pen'. pls, tell meWhy my javascript is not working like that?

//javascript
const open = document.getElementById('click');
const Skill = document.getElementsByClassName('Skill');
open.addEventListener('click' , function() {
    Skill.classList.add('show');
});
//html
  
<nav class="nav-bar">
    <div class="Logocontainer">
 <h1 class="logo"><a href="#">T&S</a></h1>
</div>
 <ul class="Menu">
     <li><a href="#home">Home</a></li>
     <li><a href="#">Team</a></li>
     <li id="click"><a href="#" id="click">My Skills</a></li>
     <li><a href="#about me">About Me</a></li>
    </ul>
</nav>
});
//css
.Skill{
    display: flex;
     margin-left: 500px;
     background-color: black;
     width: 800px;
     height: 200px;
     border-radius:10px;
     color: white;
     font-weight: bold;
     align-items: center;
     justify-content: center;
     display: none;
    }
.Skill.show{
  display:block;
    }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

getElementsByClassName retrieves a list, as you can see per the name: "elements". Plural.

change

const Skill = document.getElementsByClassName('Skill')

to

const Skill = document.getElementsByClassName('Skill')[0];

in order to access the first element with class "skill".

about 4 years ago · Juan Pablo Isaza Denunciar
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