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

158
Views
div dissapears after i click on it

i made a accordion which seems to disappear every time i click on the arrow below is my code please assist i have made a fiddle for a better understanding

JS Fiddle

     $(document).ready(function() {
    $(document).on('click','.picto-accr', function (e) {
            let id_ = $(this).data("arcid");
             $(this).toggleClass('picto-open');
             // $('.table-container').toggleClass('picto-open');

             $("#"+id_).slideToggle( "slow" );
             $('.table-container').toggle( "slow" );
         });
     });
 /*tabs*/
    #tabs_container{
        margin-top: -195px;
        width: 50%;
        margin-left: 239px;
    }

    .accr-button{
        border:1px solid  #adadad;
        padding:10px 20px;
        text-transform: uppercase;
        font-weight: 400;
        font-size: 12px;
        color: #2b2b2b;
        letter-spacing: 0.1em;
        font-family: raleway,sans-serif;
        margin-bottom: 0!important;
        cursor: pointer;
        background-color:#e1e1e1;
    }

    .picto-accr{
        width: 20px;
        float: right;
        transform: rotate(90deg);
        margin-top: 1px;
    }
    .picto-open{
        transform:rotate(270deg);
    }
    .table-container{
        padding:50px;
        display:none;
        background-color:#e1e1e1;
        border-top:1px dotted #000;
        margin-top:20px;
        text-transform:none;
    }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="biodate" class="accr-button">Bio Data<img class="picto-accr" src="http://stylenweb.com/fleche_grise_50.png" data-arcid="biodate" />
      <div class="table-container">

        test 1

      </div>
    </div>
    <div class="accr-button" id="course">Course<img class="picto-accr" src="http://stylenweb.com/fleche_grise_50.png" data-arcid="course" />
      <div class="table-container">
        test 2
      </div>
    </div>

Basically what I want to happen is for the div to stop disappearing and all it should do is collapse and expand.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Your problem is the div should be not toggle as well and you are not pointing to accordion content specifically.

$(document).ready(function() {    
     $(document).on('click','.picto-accr', function (e) {
        let id_ = $(this).data("arcid");
         $(this).toggleClass('picto-open');
         // $('.table-container').toggleClass('picto-open');

         //$("#"+id_).slideToggle( "slow" ); <-- comment this line
         $('#'+id_ +' .table-container').toggle( "slow" ); <-- make it specific
     });
 });
about 4 years ago · Juan Pablo Isaza Report

0

Well, with a little bit of inspecting you can easily find out that you are actually setting display: none to the div with id="biodate" and id="course"

For the HTML what you can do is

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="accr-button">Bio Data<img class="picto-accr" src="http://stylenweb.com/fleche_grise_50.png" data-arcid="biodate" />
      <div class="table-container"  id="biodate">

        test 1

      </div>
    </div>
    <div class="accr-button" >Course<img class="picto-accr" src="http://stylenweb.com/fleche_grise_50.png" data-arcid="course" />
      <div class="table-container" id="course">
        test 2
      </div>
    </div>

And the jQuery

$(document).ready(function() {
$(document).on('click','.picto-accr', function (e) {
        let id_ = $(this).data("arcid");
         $(this).toggleClass('picto-open');
         // $('.table-container').toggleClass('picto-open');

         $("#"+id_).slideToggle( "slow" );
     });
 });

And your accordion should be working fine now.

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!