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

152
Views
CSS/JS keep DIV hidden as default and open on click

I have a simple emoji picker and the ballon remains open as default when the page is refreshed, I can't find a way how to keep it close and only open the ballon when pressing a button.

HTML

<div class="container">                                                                            
      <div class="emoji-btn open"><img src='images/smileys.png' title='Smileys'>
       <!--this is the div I want to keep hidden till I click the button > -->  <div class="emoji-popup">
            <div class="emoji-wrapper"></div>
         </div>
      </div>
</div>

JS

emojibtn.addEventListener("click", function (e) {
   e.stopPropagation();
   this.classList.toggle("open");
});
document.body.addEventListener("click", function () {
   emojibtn.classList.remove("open");
});

CSS

.emoji-popup {
   position: absolute;
   top: -140px;
   left: 10px;
   height: 130px;
   width: 194px;
   background: #999;
   border-radius: 2px;
   text-align: left;
   overflow-y: auto;
   opacity: 0;
   pointer-events: none;
   transition: all 0.25s;
   box-sizing: border-box;
}

.emoji-wrapper {
   overflow: hidden;
   padding: 10px;
   box-sizing: border-box;
}
.emoji-popup .emoji-img {
   margin: auto;
   width: 30px;
   height: 30px;
   text-align: center;
   border-radius: 5px;
}

.emoji-popup .emoji-img:hover {
   background: rgba(0, 0, 0, 0.25);
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can add the property display: none; ( https://developer.mozilla.org/en-US/docs/Web/CSS/display), visibility: hidden(https://developer.mozilla.org/en-US/docs/Web/CSS/visibility) or opacity: 0; (https://developer.mozilla.org/en-US/docs/Web/CSS/opacity). Then onClick you can add the class open with the properties display: block (if it's a div), visibility: visible or opacity: 1.

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!