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

191
Views
How to pass arguments in AddEventListener with OOP approach

I have a question. How can I pass arguments in addEventListener inside constructor.

class Todo {
    #card = document.querySelector('.card');
    #expandButton = document.querySelector('.sidebar__expand');
    #sidebar = document.querySelector('.sidebar')
    constructor() {
        this.#card.addEventListener('mouseover',this.fadeRow.bind(this, 0.5))
        this.#card.addEventListener('mouseout',this.fadeRow.bind(this, 1))
        this.#expandButton.addEventListener('click', this.expandSidebar.bind(this))
    }

    fadeRow(e, opacity) {
            if(e.target.closest('.card__delete')) {
                const button = e.target.closest('.card__delete');
                console.log(button);
                const siblings = opacitybutton.closest('.card').querySelectorAll('.card__delete');
                siblings.forEach(sib => sib.style.opacity = '1');
                button.style.opacity = opacity;
            }
        }
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!