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

216
Views
Agregue un nuevo valor a la variable en cada nueva función que se ejecute sin perder las antiguas (jQuery)

¿Hay alguna manera de agregar una variable a las existentes en cada ejecución de función nueva, sin perder las antiguas?

Ejemplo de función:

 // this div value gets changes by an other click event <div class="data">204</div> $(".button").on('click', function(){ var data = $('.data').text(); var dataCollection = data + data; // + new data, the old ones should not be deleted console.log(dataCollection); // here I wanna see a list of all data });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

No redefina la variable cada vez. Lo que estás haciendo tendría más sentido como una matriz.

 var dataCollection = []; $(".button").on('click', function(){ var data = $('.data').text(); dataCollection.push(data) console.log(dataCollection); });
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!