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

224
Views
¿Por qué la clase JS se ejecuta dos veces?

En general, el problema es este. Creo una clase, escribo el resultado en la consola y emito el código dos veces. ¿Qué hacer?

 import { CoreValid } from "./core.component" export class Validator extends CoreValid { constructor(elementId, btn, dataName) { super(btn) this.$dataName = dataName this.$el = document.querySelector(elementId) } init() { this.$btn.addEventListener('click', this.haha.bind(this)) } haha(event) { event.preventDefault() console.log('one') } }

y su principal componente

 export class CoreValid { constructor(btn) { this.$btn = document.querySelector(btn) this.init() this.idCreate() } init() {} idCreate(){} }

Y esta es la pantalla

ingrese la descripción de la imagen aquí

Y esto es HTML

 <form action=""> <input type="text" class="main-input" placeholder="Title" data-nav="title" id="1" name=""> <div class="block-colors"> <input type="text" data-nav="color" placeholder="RGB" id="2"> </div> <button class="submit">Submit</button> </form>
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!