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

218
Views
ObservableHQ: How to give buttons in a cell click events

Is there a way I could get the buttons in this cell to have their click functionality?

Right now this cell just returns the buttons (in div.button-group) but their click functionality isn't working.

buildLegendButtons = {
  
  $('button.prev').click(function(){
    let i = parseInt($(this).attr('index'));
    if($(this).hasClass('active')){
      i = i-1;
      $(this).attr('index',i);
      $('.next').attr('index',i);
      $('.next').removeClass('deactive').addClass('active');
      if (i === 0) {
        $('.prev').addClass('deactive').removeClass('active');
      }
    }
  })

  $('button.next').click(function(){
    let i = parseInt($(this).attr('index'));
    if($(this).hasClass('active')){
      i = i+1;
      $(this).attr('index',i);
      $('.prev').attr('index',i);
      $('.prev').removeClass('deactive').addClass('active');
      if (i === insights.length-1) { 
        $('.next').addClass('deactive').removeClass('active');
      }
    }
  })

  return html`
    <div class='button-group' style='padding-left: 15px'>
      <button class='horizontal-buttons deactive prev' index='0'><</button>
      <button class='horizontal-buttons active next' index='0'>></button>
    </div>`;
}
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!