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

248
Views
Toggle Open Close Master and Modular Panel
var seg1 = true;
var seg2 = true;
var seg3 = true;

function segOne() {
    if (seg1 == true) {
        seg1 = false;
        //do close panel seg 1 
    } else {
        seg1 = true;
        //do open panel seg 1 
    }
}

function segTwo() {
    if (seg2 == true) {
        seg12 = false;
        //do close panel  seg 2
    } else {
        seg2 = true;
        //do open panel  seg 2
    }
}

function segThree() {
    if (seg3 == true) {
        seg3 = false;
        //do close panel  seg 3
    } else {
        seg3 = true;
        //do open panel  seg 3
    }
}


function opencloseAll() {
    segOne()
    segTwo()
    segThree()
    }
    
masterBtn.addEventListener('click', opencloseAll);
    
seg1Btn.addEventListener('click', segOne);

seg2Btn.addEventListener('click', segTwo);

seg3Btn.addEventListener('click', segThree);

Hi forum, I made a panel that can be toggle close and expend panel.

For now masterBtn do, it do open all and close all segment which is correct.

My question is how to do open any single segment (for example open segTwo) but when i click on masterBtn it close only opened segment.

I know I need more conditions but I cant find a right logic more than this.

Please help, Thank you!

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!