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

222
Views
Javascript class this.target is different from method and constructor

enter image description here

I want to get div.timer but this.target is always return div#root.

here's my code.

export default class Component {
    target: Element | null
    constructor(target?: Element) {
        this.target = target || $('#root')
    }
export default class Timer extends Component {
    target: Element | null
    constructor(target: Element | null, ) {
        super()
        this.target = target || $('.timer')
        console.log(this.target)                 // this return div.timer
    }
    template() {
        console.log('target', this.target)       // thus return div#root
        return ``
    }
}

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!