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

366
Views
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 answers
Answer question

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 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!